18#ifndef INCLUDE_NLOHMANN_JSON_HPP_
19#define INCLUDE_NLOHMANN_JSON_HPP_
24#include <initializer_list>
61#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
62 #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
63 #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 1
64 #warning "Already included a different version of the library!"
69#define NLOHMANN_JSON_VERSION_MAJOR 3
70#define NLOHMANN_JSON_VERSION_MINOR 11
71#define NLOHMANN_JSON_VERSION_PATCH 1
73#ifndef JSON_DIAGNOSTICS
74 #define JSON_DIAGNOSTICS 0
77#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
78 #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
82 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
84 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
87#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
88 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
90 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
93#define NLOHMANN_JSON_ABI_PREFIX_EX(major, minor, patch) \
94 json_v ## major ## _ ## minor ## _ ## patch
95#define NLOHMANN_JSON_ABI_PREFIX(major, minor, patch) \
96 NLOHMANN_JSON_ABI_PREFIX_EX(major, minor, patch)
98#define NLOHMANN_JSON_ABI_CONCAT_EX(a, b, c) a ## b ## c
99#define NLOHMANN_JSON_ABI_CONCAT(a, b, c) \
100 NLOHMANN_JSON_ABI_CONCAT_EX(a, b, c)
102#define NLOHMANN_JSON_ABI_STRING \
103 NLOHMANN_JSON_ABI_CONCAT( \
104 NLOHMANN_JSON_ABI_PREFIX( \
105 NLOHMANN_JSON_VERSION_MAJOR, \
106 NLOHMANN_JSON_VERSION_MINOR, \
107 NLOHMANN_JSON_VERSION_PATCH), \
108 NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
109 NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON)
111#ifndef NLOHMANN_JSON_NAMESPACE
112 #define NLOHMANN_JSON_NAMESPACE nlohmann::NLOHMANN_JSON_ABI_STRING
115#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
116#define NLOHMANN_JSON_NAMESPACE_BEGIN \
119 inline namespace NLOHMANN_JSON_ABI_STRING \
123#ifndef NLOHMANN_JSON_NAMESPACE_END
124#define NLOHMANN_JSON_NAMESPACE_END \
142#include <forward_list>
147#include <type_traits>
148#include <unordered_map>
208#include <type_traits>
253template<
class Default,
255 template<
class...>
class Op,
263template<
class Default,
template<
class...>
class Op,
class... Args>
270template<
template<
class...>
class Op,
class... Args>
273template<
template<
class...>
class Op,
class... Args>
276template<
template<
class...>
class Op,
class... Args>
279template<
class Default,
template<
class...>
class Op,
class... Args>
282template<
class Default,
template<
class...>
class Op,
class... Args>
285template<
class Expected,
template<
class...>
class Op,
class... Args>
288template<
class To,
template<
class...>
class Op,
class... Args>
290 std::is_convertible<
detected_t<Op, Args...>, To>;
311#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
312#if defined(JSON_HEDLEY_VERSION)
313 #undef JSON_HEDLEY_VERSION
315#define JSON_HEDLEY_VERSION 15
317#if defined(JSON_HEDLEY_STRINGIFY_EX)
318 #undef JSON_HEDLEY_STRINGIFY_EX
320#define JSON_HEDLEY_STRINGIFY_EX(x) #x
322#if defined(JSON_HEDLEY_STRINGIFY)
323 #undef JSON_HEDLEY_STRINGIFY
325#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
327#if defined(JSON_HEDLEY_CONCAT_EX)
328 #undef JSON_HEDLEY_CONCAT_EX
330#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
332#if defined(JSON_HEDLEY_CONCAT)
333 #undef JSON_HEDLEY_CONCAT
335#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
337#if defined(JSON_HEDLEY_CONCAT3_EX)
338 #undef JSON_HEDLEY_CONCAT3_EX
340#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
342#if defined(JSON_HEDLEY_CONCAT3)
343 #undef JSON_HEDLEY_CONCAT3
345#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
347#if defined(JSON_HEDLEY_VERSION_ENCODE)
348 #undef JSON_HEDLEY_VERSION_ENCODE
350#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
352#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
353 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
355#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
357#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
358 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
360#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
362#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
363 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
365#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
367#if defined(JSON_HEDLEY_GNUC_VERSION)
368 #undef JSON_HEDLEY_GNUC_VERSION
370#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
371 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
372#elif defined(__GNUC__)
373 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
376#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
377 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
379#if defined(JSON_HEDLEY_GNUC_VERSION)
380 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
382 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
385#if defined(JSON_HEDLEY_MSVC_VERSION)
386 #undef JSON_HEDLEY_MSVC_VERSION
388#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
389 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
390#elif defined(_MSC_FULL_VER) && !defined(__ICL)
391 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
392#elif defined(_MSC_VER) && !defined(__ICL)
393 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
396#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
397 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
399#if !defined(JSON_HEDLEY_MSVC_VERSION)
400 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
401#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
402 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
403#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
404 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
406 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
409#if defined(JSON_HEDLEY_INTEL_VERSION)
410 #undef JSON_HEDLEY_INTEL_VERSION
412#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
413 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
414#elif defined(__INTEL_COMPILER) && !defined(__ICL)
415 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
418#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
419 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
421#if defined(JSON_HEDLEY_INTEL_VERSION)
422 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
424 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
427#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
428 #undef JSON_HEDLEY_INTEL_CL_VERSION
430#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
431 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
434#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
435 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
437#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
438 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
440 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
443#if defined(JSON_HEDLEY_PGI_VERSION)
444 #undef JSON_HEDLEY_PGI_VERSION
446#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
447 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
450#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
451 #undef JSON_HEDLEY_PGI_VERSION_CHECK
453#if defined(JSON_HEDLEY_PGI_VERSION)
454 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
456 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
459#if defined(JSON_HEDLEY_SUNPRO_VERSION)
460 #undef JSON_HEDLEY_SUNPRO_VERSION
462#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
463 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10)
464#elif defined(__SUNPRO_C)
465 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
466#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
467 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10)
468#elif defined(__SUNPRO_CC)
469 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
472#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
473 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
475#if defined(JSON_HEDLEY_SUNPRO_VERSION)
476 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
478 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
481#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
482 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
484#if defined(__EMSCRIPTEN__)
485 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
488#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
489 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
491#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
492 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
494 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
497#if defined(JSON_HEDLEY_ARM_VERSION)
498 #undef JSON_HEDLEY_ARM_VERSION
500#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
501 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
502#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
503 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
506#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
507 #undef JSON_HEDLEY_ARM_VERSION_CHECK
509#if defined(JSON_HEDLEY_ARM_VERSION)
510 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
512 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
515#if defined(JSON_HEDLEY_IBM_VERSION)
516 #undef JSON_HEDLEY_IBM_VERSION
518#if defined(__ibmxl__)
519 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
520#elif defined(__xlC__) && defined(__xlC_ver__)
521 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
522#elif defined(__xlC__)
523 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
526#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
527 #undef JSON_HEDLEY_IBM_VERSION_CHECK
529#if defined(JSON_HEDLEY_IBM_VERSION)
530 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
532 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
535#if defined(JSON_HEDLEY_TI_VERSION)
536 #undef JSON_HEDLEY_TI_VERSION
539 defined(__TI_COMPILER_VERSION__) && \
541 defined(__TMS470__) || defined(__TI_ARM__) || \
542 defined(__MSP430__) || \
543 defined(__TMS320C2000__) \
545#if (__TI_COMPILER_VERSION__ >= 16000000)
546 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
550#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
551 #undef JSON_HEDLEY_TI_VERSION_CHECK
553#if defined(JSON_HEDLEY_TI_VERSION)
554 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
556 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
559#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
560 #undef JSON_HEDLEY_TI_CL2000_VERSION
562#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
563 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
566#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
567 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
569#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
570 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
572 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
575#if defined(JSON_HEDLEY_TI_CL430_VERSION)
576 #undef JSON_HEDLEY_TI_CL430_VERSION
578#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
579 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
582#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
583 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
585#if defined(JSON_HEDLEY_TI_CL430_VERSION)
586 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
588 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
591#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
592 #undef JSON_HEDLEY_TI_ARMCL_VERSION
594#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
595 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
598#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
599 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
601#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
602 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
604 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
607#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
608 #undef JSON_HEDLEY_TI_CL6X_VERSION
610#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
611 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
614#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
615 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
617#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
618 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
620 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
623#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
624 #undef JSON_HEDLEY_TI_CL7X_VERSION
626#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
627 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
630#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
631 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
633#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
634 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
636 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
639#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
640 #undef JSON_HEDLEY_TI_CLPRU_VERSION
642#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
643 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
646#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
647 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
649#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
650 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
652 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
655#if defined(JSON_HEDLEY_CRAY_VERSION)
656 #undef JSON_HEDLEY_CRAY_VERSION
659 #if defined(_RELEASE_PATCHLEVEL)
660 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
662 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
666#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
667 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
669#if defined(JSON_HEDLEY_CRAY_VERSION)
670 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
672 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
675#if defined(JSON_HEDLEY_IAR_VERSION)
676 #undef JSON_HEDLEY_IAR_VERSION
678#if defined(__IAR_SYSTEMS_ICC__)
680 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
682 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
686#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
687 #undef JSON_HEDLEY_IAR_VERSION_CHECK
689#if defined(JSON_HEDLEY_IAR_VERSION)
690 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
692 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
695#if defined(JSON_HEDLEY_TINYC_VERSION)
696 #undef JSON_HEDLEY_TINYC_VERSION
698#if defined(__TINYC__)
699 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
702#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
703 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
705#if defined(JSON_HEDLEY_TINYC_VERSION)
706 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
708 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
711#if defined(JSON_HEDLEY_DMC_VERSION)
712 #undef JSON_HEDLEY_DMC_VERSION
715 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
718#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
719 #undef JSON_HEDLEY_DMC_VERSION_CHECK
721#if defined(JSON_HEDLEY_DMC_VERSION)
722 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
724 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
727#if defined(JSON_HEDLEY_COMPCERT_VERSION)
728 #undef JSON_HEDLEY_COMPCERT_VERSION
730#if defined(__COMPCERT_VERSION__)
731 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
734#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
735 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
737#if defined(JSON_HEDLEY_COMPCERT_VERSION)
738 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
740 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
743#if defined(JSON_HEDLEY_PELLES_VERSION)
744 #undef JSON_HEDLEY_PELLES_VERSION
747 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
750#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
751 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
753#if defined(JSON_HEDLEY_PELLES_VERSION)
754 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
756 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
759#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
760 #undef JSON_HEDLEY_MCST_LCC_VERSION
762#if defined(__LCC__) && defined(__LCC_MINOR__)
763 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
766#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
767 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
769#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
770 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
772 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
775#if defined(JSON_HEDLEY_GCC_VERSION)
776 #undef JSON_HEDLEY_GCC_VERSION
779 defined(JSON_HEDLEY_GNUC_VERSION) && \
780 !defined(__clang__) && \
781 !defined(JSON_HEDLEY_INTEL_VERSION) && \
782 !defined(JSON_HEDLEY_PGI_VERSION) && \
783 !defined(JSON_HEDLEY_ARM_VERSION) && \
784 !defined(JSON_HEDLEY_CRAY_VERSION) && \
785 !defined(JSON_HEDLEY_TI_VERSION) && \
786 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
787 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
788 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
789 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
790 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
791 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
792 !defined(__COMPCERT__) && \
793 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
794 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
797#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
798 #undef JSON_HEDLEY_GCC_VERSION_CHECK
800#if defined(JSON_HEDLEY_GCC_VERSION)
801 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
803 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
806#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
807 #undef JSON_HEDLEY_HAS_ATTRIBUTE
810 defined(__has_attribute) && \
812 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
814# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
816# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
819#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
820 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
822#if defined(__has_attribute)
823 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
825 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
828#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
829 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
831#if defined(__has_attribute)
832 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
834 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
837#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
838 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
841 defined(__has_cpp_attribute) && \
842 defined(__cplusplus) && \
843 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
844 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
846 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
849#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
850 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
852#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
853 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
855 !defined(JSON_HEDLEY_PGI_VERSION) && \
856 !defined(JSON_HEDLEY_IAR_VERSION) && \
857 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
858 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
859 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
861 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
864#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
865 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
867#if defined(__has_cpp_attribute) && defined(__cplusplus)
868 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
870 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
873#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
874 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
876#if defined(__has_cpp_attribute) && defined(__cplusplus)
877 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
879 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
882#if defined(JSON_HEDLEY_HAS_BUILTIN)
883 #undef JSON_HEDLEY_HAS_BUILTIN
885#if defined(__has_builtin)
886 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
888 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
891#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
892 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
894#if defined(__has_builtin)
895 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
897 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
900#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
901 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
903#if defined(__has_builtin)
904 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
906 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
909#if defined(JSON_HEDLEY_HAS_FEATURE)
910 #undef JSON_HEDLEY_HAS_FEATURE
912#if defined(__has_feature)
913 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
915 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
918#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
919 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
921#if defined(__has_feature)
922 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
924 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
927#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
928 #undef JSON_HEDLEY_GCC_HAS_FEATURE
930#if defined(__has_feature)
931 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
933 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
936#if defined(JSON_HEDLEY_HAS_EXTENSION)
937 #undef JSON_HEDLEY_HAS_EXTENSION
939#if defined(__has_extension)
940 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
942 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
945#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
946 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
948#if defined(__has_extension)
949 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
951 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
954#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
955 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
957#if defined(__has_extension)
958 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
960 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
963#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
964 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
966#if defined(__has_declspec_attribute)
967 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
969 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
972#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
973 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
975#if defined(__has_declspec_attribute)
976 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
978 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
981#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
982 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
984#if defined(__has_declspec_attribute)
985 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
987 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
990#if defined(JSON_HEDLEY_HAS_WARNING)
991 #undef JSON_HEDLEY_HAS_WARNING
993#if defined(__has_warning)
994 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
996 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
999#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
1000 #undef JSON_HEDLEY_GNUC_HAS_WARNING
1002#if defined(__has_warning)
1003 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1005 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1008#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
1009 #undef JSON_HEDLEY_GCC_HAS_WARNING
1011#if defined(__has_warning)
1012 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1014 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1018 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1019 defined(__clang__) || \
1020 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1021 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1022 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1023 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
1024 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1025 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1026 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1027 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1028 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1029 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
1030 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1031 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1032 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
1033 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
1034 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
1035 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
1036 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
1037#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1038 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
1040 #define JSON_HEDLEY_PRAGMA(value)
1043#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
1044 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
1046#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
1047 #undef JSON_HEDLEY_DIAGNOSTIC_POP
1049#if defined(__clang__)
1050 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1051 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1052#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1053 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1054 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1055#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1056 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1057 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1059 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
1060 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1061 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
1062 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
1063#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
1064 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
1065 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
1067 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1068 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1069 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
1070 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1071 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1072 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1073 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
1074 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
1075#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1076 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1077 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1079 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
1080 #define JSON_HEDLEY_DIAGNOSTIC_POP
1085#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1086 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
1088#if defined(__cplusplus)
1089# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
1090# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
1091# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
1092# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1093 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1094 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1095 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1096 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
1098 JSON_HEDLEY_DIAGNOSTIC_POP
1100# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1101 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1102 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1103 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1105 JSON_HEDLEY_DIAGNOSTIC_POP
1108# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1109 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1110 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1112 JSON_HEDLEY_DIAGNOSTIC_POP
1116#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1117 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
1120#if defined(JSON_HEDLEY_CONST_CAST)
1121 #undef JSON_HEDLEY_CONST_CAST
1123#if defined(__cplusplus)
1124# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1126 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1127 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1128 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1129# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1130 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1131 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1133 JSON_HEDLEY_DIAGNOSTIC_POP \
1136# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1139#if defined(JSON_HEDLEY_REINTERPRET_CAST)
1140 #undef JSON_HEDLEY_REINTERPRET_CAST
1142#if defined(__cplusplus)
1143 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1145 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1148#if defined(JSON_HEDLEY_STATIC_CAST)
1149 #undef JSON_HEDLEY_STATIC_CAST
1151#if defined(__cplusplus)
1152 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1154 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1157#if defined(JSON_HEDLEY_CPP_CAST)
1158 #undef JSON_HEDLEY_CPP_CAST
1160#if defined(__cplusplus)
1161# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1162# define JSON_HEDLEY_CPP_CAST(T, expr) \
1163 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1164 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1166 JSON_HEDLEY_DIAGNOSTIC_POP
1167# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1168# define JSON_HEDLEY_CPP_CAST(T, expr) \
1169 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1170 _Pragma("diag_suppress=Pe137") \
1171 JSON_HEDLEY_DIAGNOSTIC_POP
1173# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1176# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1179#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1180 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1182#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1183 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1184#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1185 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1186#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1187 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1188#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1189 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1190#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1191 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1192#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1193 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1194#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1195 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1196#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1197 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1199 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1200 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1201 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1202 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1203 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1204 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1205 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1206 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1207 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1208 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1209 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1210 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1211#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1212 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1213#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1214 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1215#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1216 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1217#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1218 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1220 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1223#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1224 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1226#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1227 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1228#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1229 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1230#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1231 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1232#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1233 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1234#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1235 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1236#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1237 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1239 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1240 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1241 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1242 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1243 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1244#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1245 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1246#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1247 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1248#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1249 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1251 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1254#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1255 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1257#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1258 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1259#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1260 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1261#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1262 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1263#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1264 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1265#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1266 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1267#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1268 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1269#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1270 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1271#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1272 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1274 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1275 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1276 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1277 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1278#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1279 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1280#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1281 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1283 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1286#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1287 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1289#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1290 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1291#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1292 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1293#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1294 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1296 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1299#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1300 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1302#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1303 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1304#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1305 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1306#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1307 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1308#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1309 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1311 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1314#if defined(JSON_HEDLEY_DEPRECATED)
1315 #undef JSON_HEDLEY_DEPRECATED
1317#if defined(JSON_HEDLEY_DEPRECATED_FOR)
1318 #undef JSON_HEDLEY_DEPRECATED_FOR
1321 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1322 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1323 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1324 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1326 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1327 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1328 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1329 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1330 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1331 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1332 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1333 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1334 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1335 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1336 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1337 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1338 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1339 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1340#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1341 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1342 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1344 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1345 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1346 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1347 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1348 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1349 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1350 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1351 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1352 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1353 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1354 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1355 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1356 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1357 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1358 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1359 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1360 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1361 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1363 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1364 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1365 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1366 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1367 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1368#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1369 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1370 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1372 #define JSON_HEDLEY_DEPRECATED(since)
1373 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1376#if defined(JSON_HEDLEY_UNAVAILABLE)
1377 #undef JSON_HEDLEY_UNAVAILABLE
1380 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1381 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1382 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1383 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1384 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1386 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1389#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1390 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1392#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1393 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1396 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1397 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1398 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1399 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1400 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1401 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1402 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1403 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1404 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1405 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1406 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1407 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1408 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1409 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1410 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1411 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1412 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1413 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1414 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1415#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1416 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1417 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1418#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1419 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1420 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1421#elif defined(_Check_return_)
1422 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1423 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1425 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1426 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1429#if defined(JSON_HEDLEY_SENTINEL)
1430 #undef JSON_HEDLEY_SENTINEL
1433 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1434 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1435 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1436 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1437 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1438 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1440 #define JSON_HEDLEY_SENTINEL(position)
1443#if defined(JSON_HEDLEY_NO_RETURN)
1444 #undef JSON_HEDLEY_NO_RETURN
1446#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1447 #define JSON_HEDLEY_NO_RETURN __noreturn
1449 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1450 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1451 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1452#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1453 #define JSON_HEDLEY_NO_RETURN _Noreturn
1454#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1455 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1457 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1458 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1459 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1460 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1461 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1462 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1463 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1464 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1465 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1466 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1467 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1468 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1469 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1470 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1471 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1472 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1473 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1474 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1475#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1476 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1478 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1479 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1480 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1481#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1482 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1483#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1484 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1485#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1486 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1488 #define JSON_HEDLEY_NO_RETURN
1491#if defined(JSON_HEDLEY_NO_ESCAPE)
1492 #undef JSON_HEDLEY_NO_ESCAPE
1494#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1495 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1497 #define JSON_HEDLEY_NO_ESCAPE
1500#if defined(JSON_HEDLEY_UNREACHABLE)
1501 #undef JSON_HEDLEY_UNREACHABLE
1503#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1504 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1506#if defined(JSON_HEDLEY_ASSUME)
1507 #undef JSON_HEDLEY_ASSUME
1510 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1511 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1512 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1513 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1514#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1515 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1517 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1518 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1519 #if defined(__cplusplus)
1520 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1522 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1526 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1527 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1528 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1529 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1530 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1531 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1532 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1533 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1534#elif defined(JSON_HEDLEY_ASSUME)
1535 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1537#if !defined(JSON_HEDLEY_ASSUME)
1538 #if defined(JSON_HEDLEY_UNREACHABLE)
1539 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1541 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1544#if defined(JSON_HEDLEY_UNREACHABLE)
1546 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1547 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1548 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1550 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1553 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1555#if !defined(JSON_HEDLEY_UNREACHABLE)
1556 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1560#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1561 #pragma clang diagnostic ignored "-Wpedantic"
1563#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1564 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1566#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1567 #if defined(__clang__)
1568 #pragma clang diagnostic ignored "-Wvariadic-macros"
1569 #elif defined(JSON_HEDLEY_GCC_VERSION)
1570 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1573#if defined(JSON_HEDLEY_NON_NULL)
1574 #undef JSON_HEDLEY_NON_NULL
1577 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1578 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1579 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1580 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1581 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1583 #define JSON_HEDLEY_NON_NULL(...)
1587#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1588 #undef JSON_HEDLEY_PRINTF_FORMAT
1590#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1591 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1592#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1593 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1595 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1596 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1597 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1598 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1599 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1600 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1601 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1602 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1603 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1604 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1605 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1606 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1607 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1608 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1609 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1610 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1611 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1612 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1613#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1614 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1616 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1619#if defined(JSON_HEDLEY_CONSTEXPR)
1620 #undef JSON_HEDLEY_CONSTEXPR
1622#if defined(__cplusplus)
1623 #if __cplusplus >= 201103L
1624 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1627#if !defined(JSON_HEDLEY_CONSTEXPR)
1628 #define JSON_HEDLEY_CONSTEXPR
1631#if defined(JSON_HEDLEY_PREDICT)
1632 #undef JSON_HEDLEY_PREDICT
1634#if defined(JSON_HEDLEY_LIKELY)
1635 #undef JSON_HEDLEY_LIKELY
1637#if defined(JSON_HEDLEY_UNLIKELY)
1638 #undef JSON_HEDLEY_UNLIKELY
1640#if defined(JSON_HEDLEY_UNPREDICTABLE)
1641 #undef JSON_HEDLEY_UNPREDICTABLE
1643#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1644 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1647 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1648 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1649 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1650# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1651# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1652# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1653# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1654# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1656 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1657 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1658 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1659 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1660 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1661 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1662 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1663 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1664 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1665 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1666 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1667 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1668 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1669 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1670 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1671 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1672# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1673 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1674# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1676 double hedley_probability_ = (probability); \
1677 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1679# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1681 double hedley_probability_ = (probability); \
1682 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1684# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1685# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1687# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1688# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1689# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1690# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1691# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1693#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1694 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1697#if defined(JSON_HEDLEY_MALLOC)
1698 #undef JSON_HEDLEY_MALLOC
1701 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1702 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1703 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1704 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1705 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1706 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1707 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1708 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1709 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1710 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1711 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1712 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1713 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1714 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1715 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1716 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1717 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1718 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1719 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1720#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1721 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1723 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1724 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1725 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1727 #define JSON_HEDLEY_MALLOC
1730#if defined(JSON_HEDLEY_PURE)
1731 #undef JSON_HEDLEY_PURE
1734 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1735 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1736 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1737 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1738 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1739 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1740 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1741 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1742 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1743 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1744 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1745 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1746 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1747 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1748 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1749 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1750 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1751 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1752 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1753# define JSON_HEDLEY_PURE __attribute__((__pure__))
1754#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1755# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1756#elif defined(__cplusplus) && \
1758 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1759 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1760 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1762# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1764# define JSON_HEDLEY_PURE
1767#if defined(JSON_HEDLEY_CONST)
1768 #undef JSON_HEDLEY_CONST
1771 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1772 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1773 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1774 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1775 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1776 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1777 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1778 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1779 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1780 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1781 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1782 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1783 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1784 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1785 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1786 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1787 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1788 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1789 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1790 #define JSON_HEDLEY_CONST __attribute__((__const__))
1792 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1793 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1795 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1798#if defined(JSON_HEDLEY_RESTRICT)
1799 #undef JSON_HEDLEY_RESTRICT
1801#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1802 #define JSON_HEDLEY_RESTRICT restrict
1804 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1805 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1806 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1807 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1808 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1809 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1810 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1811 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1812 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1813 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1814 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1815 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1816 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1817 defined(__clang__) || \
1818 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1819 #define JSON_HEDLEY_RESTRICT __restrict
1820#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1821 #define JSON_HEDLEY_RESTRICT _Restrict
1823 #define JSON_HEDLEY_RESTRICT
1826#if defined(JSON_HEDLEY_INLINE)
1827 #undef JSON_HEDLEY_INLINE
1830 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1831 (defined(__cplusplus) && (__cplusplus >= 199711L))
1832 #define JSON_HEDLEY_INLINE inline
1834 defined(JSON_HEDLEY_GCC_VERSION) || \
1835 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1836 #define JSON_HEDLEY_INLINE __inline__
1838 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1839 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1840 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1841 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1842 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1843 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1844 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1845 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1846 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1847 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1848 #define JSON_HEDLEY_INLINE __inline
1850 #define JSON_HEDLEY_INLINE
1853#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1854 #undef JSON_HEDLEY_ALWAYS_INLINE
1857 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1858 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1859 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1860 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1861 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1862 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1863 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1864 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1865 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1866 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1867 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1868 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1869 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1870 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1871 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1872 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1873 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1874 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1875 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1876# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1878 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1879 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1880# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1881#elif defined(__cplusplus) && \
1883 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1884 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1885 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1886 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1887 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1888 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1890# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1891#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1892# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1894# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1897#if defined(JSON_HEDLEY_NEVER_INLINE)
1898 #undef JSON_HEDLEY_NEVER_INLINE
1901 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1902 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1903 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1904 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1905 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1906 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1907 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1908 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1909 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1910 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1911 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1912 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1913 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1914 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1915 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1916 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1917 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1918 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1919 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1920 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1922 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1923 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1924 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1925#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1926 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1927#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1928 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1929#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1930 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1931#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1932 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1933#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1934 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1936 #define JSON_HEDLEY_NEVER_INLINE
1939#if defined(JSON_HEDLEY_PRIVATE)
1940 #undef JSON_HEDLEY_PRIVATE
1942#if defined(JSON_HEDLEY_PUBLIC)
1943 #undef JSON_HEDLEY_PUBLIC
1945#if defined(JSON_HEDLEY_IMPORT)
1946 #undef JSON_HEDLEY_IMPORT
1948#if defined(_WIN32) || defined(__CYGWIN__)
1949# define JSON_HEDLEY_PRIVATE
1950# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1951# define JSON_HEDLEY_IMPORT __declspec(dllimport)
1954 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1955 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1956 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1957 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1958 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1959 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1961 defined(__TI_EABI__) && \
1963 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1964 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
1967 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1968# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
1969# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
1971# define JSON_HEDLEY_PRIVATE
1972# define JSON_HEDLEY_PUBLIC
1974# define JSON_HEDLEY_IMPORT extern
1977#if defined(JSON_HEDLEY_NO_THROW)
1978 #undef JSON_HEDLEY_NO_THROW
1981 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
1982 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1983 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1984 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1985 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
1987 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
1988 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1989 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1990 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
1992 #define JSON_HEDLEY_NO_THROW
1995#if defined(JSON_HEDLEY_FALL_THROUGH)
1996 #undef JSON_HEDLEY_FALL_THROUGH
1999 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
2000 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
2001 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2002 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
2003#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
2004 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
2005#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
2006 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
2007#elif defined(__fallthrough)
2008 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
2010 #define JSON_HEDLEY_FALL_THROUGH
2013#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
2014 #undef JSON_HEDLEY_RETURNS_NON_NULL
2017 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
2018 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2019 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2020 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
2021#elif defined(_Ret_notnull_)
2022 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
2024 #define JSON_HEDLEY_RETURNS_NON_NULL
2027#if defined(JSON_HEDLEY_ARRAY_PARAM)
2028 #undef JSON_HEDLEY_ARRAY_PARAM
2031 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
2032 !defined(__STDC_NO_VLA__) && \
2033 !defined(__cplusplus) && \
2034 !defined(JSON_HEDLEY_PGI_VERSION) && \
2035 !defined(JSON_HEDLEY_TINYC_VERSION)
2036 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
2038 #define JSON_HEDLEY_ARRAY_PARAM(name)
2041#if defined(JSON_HEDLEY_IS_CONSTANT)
2042 #undef JSON_HEDLEY_IS_CONSTANT
2044#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
2045 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
2049#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2050 #undef JSON_HEDLEY_IS_CONSTEXPR_
2053 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
2054 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2055 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2056 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
2057 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
2058 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2059 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
2060 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
2061 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2062 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2063 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
2065#if !defined(__cplusplus)
2067 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
2068 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2069 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2070 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2071 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2072 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
2073 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
2074#if defined(__INTPTR_TYPE__)
2075 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
2078 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
2082 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
2083 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
2084 !defined(JSON_HEDLEY_PGI_VERSION) && \
2085 !defined(JSON_HEDLEY_IAR_VERSION)) || \
2086 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
2087 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2088 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
2089 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
2090 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
2091#if defined(__INTPTR_TYPE__)
2092 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
2095 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
2098 defined(JSON_HEDLEY_GCC_VERSION) || \
2099 defined(JSON_HEDLEY_INTEL_VERSION) || \
2100 defined(JSON_HEDLEY_TINYC_VERSION) || \
2101 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
2102 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
2103 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
2104 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
2105 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
2106 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
2108# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
2112 ((void*) ((expr) * 0L) ) : \
2113((struct { char v[sizeof(void) * 2]; } *) 1) \
2119#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2120 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2121 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
2123 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
2125 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2126 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2128 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2131#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2132 #undef JSON_HEDLEY_BEGIN_C_DECLS
2134#if defined(JSON_HEDLEY_END_C_DECLS)
2135 #undef JSON_HEDLEY_END_C_DECLS
2137#if defined(JSON_HEDLEY_C_DECL)
2138 #undef JSON_HEDLEY_C_DECL
2140#if defined(__cplusplus)
2141 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2142 #define JSON_HEDLEY_END_C_DECLS }
2143 #define JSON_HEDLEY_C_DECL extern "C"
2145 #define JSON_HEDLEY_BEGIN_C_DECLS
2146 #define JSON_HEDLEY_END_C_DECLS
2147 #define JSON_HEDLEY_C_DECL
2150#if defined(JSON_HEDLEY_STATIC_ASSERT)
2151 #undef JSON_HEDLEY_STATIC_ASSERT
2154 !defined(__cplusplus) && ( \
2155 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2156 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2157 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2158 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2159 defined(_Static_assert) \
2161# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2163 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2164 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2165 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2166# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2168# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2171#if defined(JSON_HEDLEY_NULL)
2172 #undef JSON_HEDLEY_NULL
2174#if defined(__cplusplus)
2175 #if __cplusplus >= 201103L
2176 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2178 #define JSON_HEDLEY_NULL NULL
2180 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2183 #define JSON_HEDLEY_NULL NULL
2185 #define JSON_HEDLEY_NULL ((void*) 0)
2188#if defined(JSON_HEDLEY_MESSAGE)
2189 #undef JSON_HEDLEY_MESSAGE
2191#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2192# define JSON_HEDLEY_MESSAGE(msg) \
2193 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2194 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2195 JSON_HEDLEY_PRAGMA(message msg) \
2196 JSON_HEDLEY_DIAGNOSTIC_POP
2198 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2199 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2200# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2201#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2202# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2203#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2204# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2205#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2206# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2208# define JSON_HEDLEY_MESSAGE(msg)
2211#if defined(JSON_HEDLEY_WARNING)
2212 #undef JSON_HEDLEY_WARNING
2214#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2215# define JSON_HEDLEY_WARNING(msg) \
2216 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2217 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2218 JSON_HEDLEY_PRAGMA(clang warning msg) \
2219 JSON_HEDLEY_DIAGNOSTIC_POP
2221 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2222 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2223 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2224# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2226 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2227 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2228# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2230# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2233#if defined(JSON_HEDLEY_REQUIRE)
2234 #undef JSON_HEDLEY_REQUIRE
2236#if defined(JSON_HEDLEY_REQUIRE_MSG)
2237 #undef JSON_HEDLEY_REQUIRE_MSG
2239#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2240# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2241# define JSON_HEDLEY_REQUIRE(expr) \
2242 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2243 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2244 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2245 JSON_HEDLEY_DIAGNOSTIC_POP
2246# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2247 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2248 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2249 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2250 JSON_HEDLEY_DIAGNOSTIC_POP
2252# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2253# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2256# define JSON_HEDLEY_REQUIRE(expr)
2257# define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2260#if defined(JSON_HEDLEY_FLAGS)
2261 #undef JSON_HEDLEY_FLAGS
2263#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2264 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2266 #define JSON_HEDLEY_FLAGS
2269#if defined(JSON_HEDLEY_FLAGS_CAST)
2270 #undef JSON_HEDLEY_FLAGS_CAST
2272#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2273# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2274 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2275 _Pragma("warning(disable:188)") \
2277 JSON_HEDLEY_DIAGNOSTIC_POP \
2280# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2283#if defined(JSON_HEDLEY_EMPTY_BASES)
2284 #undef JSON_HEDLEY_EMPTY_BASES
2287 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2288 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2289 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2291 #define JSON_HEDLEY_EMPTY_BASES
2296#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2297 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2299#if defined(__clang__)
2300 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2302 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2305#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2306 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2308#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2310#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2311 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2313#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2315#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2316 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2318#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2320#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2321 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2323#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2325#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2326 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2328#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2330#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2331 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2333#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2335#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2336 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2338#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2350#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2351 #if defined(__clang__)
2352 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2353 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2355 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2356 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2357 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2364#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2365 #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2366 #define JSON_HAS_CPP_20
2367 #define JSON_HAS_CPP_17
2368 #define JSON_HAS_CPP_14
2369 #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2370 #define JSON_HAS_CPP_17
2371 #define JSON_HAS_CPP_14
2372 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2373 #define JSON_HAS_CPP_14
2376 #define JSON_HAS_CPP_11
2380 #if __has_include(<version>)
2385#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2386 #ifdef JSON_HAS_CPP_17
2387 #if defined(__cpp_lib_filesystem)
2388 #define JSON_HAS_FILESYSTEM 1
2389 #elif defined(__cpp_lib_experimental_filesystem)
2390 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2391 #elif !defined(__has_include)
2392 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2393 #elif __has_include(<filesystem>)
2394 #define JSON_HAS_FILESYSTEM 1
2395 #elif __has_include(<experimental/filesystem>)
2396 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2400 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2401 #undef JSON_HAS_FILESYSTEM
2402 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2406 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2407 #undef JSON_HAS_FILESYSTEM
2408 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2412 #if defined(__clang_major__) && __clang_major__ < 7
2413 #undef JSON_HAS_FILESYSTEM
2414 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2418 #if defined(_MSC_VER) && _MSC_VER < 1914
2419 #undef JSON_HAS_FILESYSTEM
2420 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2424 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2425 #undef JSON_HAS_FILESYSTEM
2426 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2430 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2431 #undef JSON_HAS_FILESYSTEM
2432 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2437#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2438 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2441#ifndef JSON_HAS_FILESYSTEM
2442 #define JSON_HAS_FILESYSTEM 0
2445#ifndef JSON_HAS_THREE_WAY_COMPARISON
2446 #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \
2447 && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L
2448 #define JSON_HAS_THREE_WAY_COMPARISON 1
2450 #define JSON_HAS_THREE_WAY_COMPARISON 0
2454#ifndef JSON_HAS_RANGES
2456 #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427
2457 #define JSON_HAS_RANGES 0
2458 #elif defined(__cpp_lib_ranges)
2459 #define JSON_HAS_RANGES 1
2461 #define JSON_HAS_RANGES 0
2465#ifdef JSON_HAS_CPP_17
2466 #define JSON_INLINE_VARIABLE inline
2468 #define JSON_INLINE_VARIABLE
2471#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address)
2472 #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]]
2474 #define JSON_NO_UNIQUE_ADDRESS
2478#if defined(__clang__)
2479 #pragma clang diagnostic push
2480 #pragma clang diagnostic ignored "-Wdocumentation"
2481 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2485#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2486 #define JSON_THROW(exception) throw exception
2487 #define JSON_TRY try
2488 #define JSON_CATCH(exception) catch(exception)
2489 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2492 #define JSON_THROW(exception) std::abort()
2493 #define JSON_TRY if(true)
2494 #define JSON_CATCH(exception) if(false)
2495 #define JSON_INTERNAL_CATCH(exception) if(false)
2499#if defined(JSON_THROW_USER)
2501 #define JSON_THROW JSON_THROW_USER
2503#if defined(JSON_TRY_USER)
2505 #define JSON_TRY JSON_TRY_USER
2507#if defined(JSON_CATCH_USER)
2509 #define JSON_CATCH JSON_CATCH_USER
2510 #undef JSON_INTERNAL_CATCH
2511 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2513#if defined(JSON_INTERNAL_CATCH_USER)
2514 #undef JSON_INTERNAL_CATCH
2515 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2519#if !defined(JSON_ASSERT)
2521 #define JSON_ASSERT(x) assert(x)
2525#if defined(JSON_TESTS_PRIVATE)
2526 #define JSON_PRIVATE_UNLESS_TESTED public
2528 #define JSON_PRIVATE_UNLESS_TESTED private
2536#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2537 template<typename BasicJsonType> \
2538 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2540 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2541 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2542 auto it = std::find_if(std::begin(m), std::end(m), \
2543 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2545 return ej_pair.first == e; \
2547 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2549 template<typename BasicJsonType> \
2550 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2552 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2553 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2554 auto it = std::find_if(std::begin(m), std::end(m), \
2555 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2557 return ej_pair.second == j; \
2559 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2565#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2566 template<template<typename, typename, typename...> class ObjectType, \
2567 template<typename, typename...> class ArrayType, \
2568 class StringType, class BooleanType, class NumberIntegerType, \
2569 class NumberUnsignedType, class NumberFloatType, \
2570 template<typename> class AllocatorType, \
2571 template<typename, typename = void> class JSONSerializer, \
2574#define NLOHMANN_BASIC_JSON_TPL \
2575 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2576 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2577 AllocatorType, JSONSerializer, BinaryType>
2581#define NLOHMANN_JSON_EXPAND( x ) x
2582#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME
2583#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2584 NLOHMANN_JSON_PASTE64, \
2585 NLOHMANN_JSON_PASTE63, \
2586 NLOHMANN_JSON_PASTE62, \
2587 NLOHMANN_JSON_PASTE61, \
2588 NLOHMANN_JSON_PASTE60, \
2589 NLOHMANN_JSON_PASTE59, \
2590 NLOHMANN_JSON_PASTE58, \
2591 NLOHMANN_JSON_PASTE57, \
2592 NLOHMANN_JSON_PASTE56, \
2593 NLOHMANN_JSON_PASTE55, \
2594 NLOHMANN_JSON_PASTE54, \
2595 NLOHMANN_JSON_PASTE53, \
2596 NLOHMANN_JSON_PASTE52, \
2597 NLOHMANN_JSON_PASTE51, \
2598 NLOHMANN_JSON_PASTE50, \
2599 NLOHMANN_JSON_PASTE49, \
2600 NLOHMANN_JSON_PASTE48, \
2601 NLOHMANN_JSON_PASTE47, \
2602 NLOHMANN_JSON_PASTE46, \
2603 NLOHMANN_JSON_PASTE45, \
2604 NLOHMANN_JSON_PASTE44, \
2605 NLOHMANN_JSON_PASTE43, \
2606 NLOHMANN_JSON_PASTE42, \
2607 NLOHMANN_JSON_PASTE41, \
2608 NLOHMANN_JSON_PASTE40, \
2609 NLOHMANN_JSON_PASTE39, \
2610 NLOHMANN_JSON_PASTE38, \
2611 NLOHMANN_JSON_PASTE37, \
2612 NLOHMANN_JSON_PASTE36, \
2613 NLOHMANN_JSON_PASTE35, \
2614 NLOHMANN_JSON_PASTE34, \
2615 NLOHMANN_JSON_PASTE33, \
2616 NLOHMANN_JSON_PASTE32, \
2617 NLOHMANN_JSON_PASTE31, \
2618 NLOHMANN_JSON_PASTE30, \
2619 NLOHMANN_JSON_PASTE29, \
2620 NLOHMANN_JSON_PASTE28, \
2621 NLOHMANN_JSON_PASTE27, \
2622 NLOHMANN_JSON_PASTE26, \
2623 NLOHMANN_JSON_PASTE25, \
2624 NLOHMANN_JSON_PASTE24, \
2625 NLOHMANN_JSON_PASTE23, \
2626 NLOHMANN_JSON_PASTE22, \
2627 NLOHMANN_JSON_PASTE21, \
2628 NLOHMANN_JSON_PASTE20, \
2629 NLOHMANN_JSON_PASTE19, \
2630 NLOHMANN_JSON_PASTE18, \
2631 NLOHMANN_JSON_PASTE17, \
2632 NLOHMANN_JSON_PASTE16, \
2633 NLOHMANN_JSON_PASTE15, \
2634 NLOHMANN_JSON_PASTE14, \
2635 NLOHMANN_JSON_PASTE13, \
2636 NLOHMANN_JSON_PASTE12, \
2637 NLOHMANN_JSON_PASTE11, \
2638 NLOHMANN_JSON_PASTE10, \
2639 NLOHMANN_JSON_PASTE9, \
2640 NLOHMANN_JSON_PASTE8, \
2641 NLOHMANN_JSON_PASTE7, \
2642 NLOHMANN_JSON_PASTE6, \
2643 NLOHMANN_JSON_PASTE5, \
2644 NLOHMANN_JSON_PASTE4, \
2645 NLOHMANN_JSON_PASTE3, \
2646 NLOHMANN_JSON_PASTE2, \
2647 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2648#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2649#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2650#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2651#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2652#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2653#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6)
2654#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7)
2655#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8)
2656#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9)
2657#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10)
2658#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11)
2659#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12)
2660#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13)
2661#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14)
2662#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)
2663#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16)
2664#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)
2665#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
2666#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19)
2667#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20)
2668#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21)
2669#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22)
2670#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23)
2671#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24)
2672#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25)
2673#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26)
2674#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27)
2675#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28)
2676#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29)
2677#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30)
2678#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31)
2679#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32)
2680#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33)
2681#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34)
2682#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35)
2683#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36)
2684#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37)
2685#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38)
2686#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39)
2687#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40)
2688#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41)
2689#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42)
2690#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43)
2691#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44)
2692#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45)
2693#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46)
2694#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47)
2695#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48)
2696#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49)
2697#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50)
2698#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51)
2699#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52)
2700#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53)
2701#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54)
2702#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55)
2703#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56)
2704#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57)
2705#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58)
2706#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59)
2707#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60)
2708#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61)
2709#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62)
2710#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63)
2712#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2713#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2714#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1);
2721#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2722 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2723 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2725#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2726 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2727 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2734#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2735 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2736 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2738#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2739 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2740 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2749#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2750 namespace detail { \
2751 using std::std_name; \
2753 template<typename... T> \
2754 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2757 namespace detail2 { \
2758 struct std_name##_tag \
2762 template<typename... T> \
2763 std_name##_tag std_name(T&&...); \
2765 template<typename... T> \
2766 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2768 template<typename... T> \
2769 struct would_call_std_##std_name \
2771 static constexpr auto const value = ::nlohmann::detail:: \
2772 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2776 template<typename... T> \
2777 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2781#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2782 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2785#if JSON_USE_IMPLICIT_CONVERSIONS
2786 #define JSON_EXPLICIT
2788 #define JSON_EXPLICIT explicit
2791#ifndef JSON_DISABLE_ENUM_SERIALIZATION
2792 #define JSON_DISABLE_ENUM_SERIALIZATION 0
2795#ifndef JSON_USE_GLOBAL_UDLS
2796 #define JSON_USE_GLOBAL_UDLS 1
2799#if JSON_HAS_THREE_WAY_COMPARISON
2862#if JSON_HAS_THREE_WAY_COMPARISON
2863 inline std::partial_ordering operator<=>(
const value_t lhs,
const value_t rhs)
noexcept
2868 static constexpr std::array<std::uint8_t, 9> order = {{
2875 const auto l_index =
static_cast<std::size_t
>(lhs);
2876 const auto r_index =
static_cast<std::size_t
>(rhs);
2877#if JSON_HAS_THREE_WAY_COMPARISON
2878 if (l_index < order.size() && r_index < order.size())
2880 return order[l_index] <=> order[r_index];
2882 return std::partial_ordering::unordered;
2884 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
2892#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__)
2895 return std::is_lt(lhs <=> rhs);
2933template<
typename StringType>
2935 const StringType& t)
2938 for (
auto pos = s.find(
f);
2939 pos != StringType::npos;
2940 s.replace(pos,
f.size(), t),
2941 pos = s.find(
f, pos + t.size()))
2952template<
typename StringType>
2967template<
typename StringType>
3008 constexpr operator size_t()
const
3032#include <type_traits>
3043using uncvref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
3045#ifdef JSON_HAS_CPP_14
3056template<
bool B,
typename T =
void>
3083template <
typename T, T... Ints>
3087 static constexpr std::size_t
size() noexcept
3089 return sizeof...(Ints);
3098template <
size_t... Ints>
3101namespace utility_internal
3104template <
typename Seq,
size_t SeqSize,
size_t Rem>
3108template <
typename T, T... Ints,
size_t SeqSize>
3114template <
typename T, T... Ints,
size_t SeqSize>
3122template <
typename T,
size_t N>
3129template <
typename T>
3144template <
typename T, T N>
3160template <
typename... Ts>
3178#ifndef JSON_HAS_CPP_17
3180 template<
typename T>
3200#include <type_traits>
3228template<
typename It,
typename =
void>
3231template<
typename It>
3235 typename It::reference, typename It::iterator_category >>
3246template<
typename T,
typename =
void>
3325#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3326 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3351 template<
typename T =
void,
typename SFINAE =
void>
3356 template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3358 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3359 class StringType = std::string,
class BooleanType = bool,
3360 class NumberIntegerType = std::int64_t,
3361 class NumberUnsignedType = std::uint64_t,
3362 class NumberFloatType = double,
3363 template<
typename U>
class AllocatorType = std::allocator,
3364 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3366 class BinaryType = std::vector<std::uint8_t>>
3371 template<
typename BasicJsonType>
3382 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3427template<
typename BasicJsonContext>
3429 std::integral_constant < bool,
3430 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
3431 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
3472template<
typename T,
typename... Args>
3475template<
typename T,
typename... Args>
3478template<
typename T,
typename U>
3482template<
typename BasicJsonType,
typename T,
typename =
void>
3489template <
typename BasicJsonType,
typename T>
3495template<
typename BasicJsonType,
typename T>
3498 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3502 const BasicJsonType&, T&>::value;
3507template<
typename BasicJsonType,
typename T,
typename =
void>
3510template<
typename BasicJsonType,
typename T>
3513 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3517 const BasicJsonType&>::value;
3522template<
typename BasicJsonType,
typename T,
typename =
void>
3525template<
typename BasicJsonType,
typename T>
3528 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3539struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3542template<
typename BasicJsonType>
3547 using type =
typename std::conditional < has_key_compare<object_t>::value,
3551template<
typename BasicJsonType>
3561template<
class B,
class... Bn>
3563: std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>::type {};
3566template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3571template <
typename T>
3574template <
typename T1,
typename T2>
3576 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3578template <
typename T1,
typename T2>
3580 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3582template <
typename... Ts>
3584 :
conjunction<is_default_constructible<Ts>...> {};
3586template <
typename... Ts>
3588 :
conjunction<is_default_constructible<Ts>...> {};
3591template <
typename T,
typename... Args>
3594template <
typename T1,
typename T2>
3597template <
typename T1,
typename T2>
3600template <
typename... Ts>
3603template <
typename... Ts>
3607template<
typename T,
typename =
void>
3629 using t_ref =
typename std::add_lvalue_reference<T>::type;
3641 static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value &&
is_iterator_begin;
3654template<
typename T,
typename =
void>
3660template<
typename BasicJsonType,
typename CompatibleObjectType,
3664template<
typename BasicJsonType,
typename CompatibleObjectType>
3666 BasicJsonType, CompatibleObjectType,
3668 is_detected<key_type_t, CompatibleObjectType>::value >>
3675 typename CompatibleObjectType::key_type>::value &&
3677 typename CompatibleObjectType::mapped_type>::value;
3680template<
typename BasicJsonType,
typename CompatibleObjectType>
3684template<
typename BasicJsonType,
typename ConstructibleObjectType,
3688template<
typename BasicJsonType,
typename ConstructibleObjectType>
3690 BasicJsonType, ConstructibleObjectType,
3692 is_detected<key_type_t, ConstructibleObjectType>::value >>
3698 (std::is_move_assignable<ConstructibleObjectType>::value ||
3699 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3701 typename object_t::key_type>::value &&
3703 typename object_t::mapped_type,
3704 typename ConstructibleObjectType::mapped_type >::value)) ||
3706 typename ConstructibleObjectType::mapped_type>::value ||
3709 typename ConstructibleObjectType::mapped_type >::value);
3712template<
typename BasicJsonType,
typename ConstructibleObjectType>
3715 ConstructibleObjectType> {};
3717template<
typename BasicJsonType,
typename CompatibleStringType>
3724template<
typename BasicJsonType,
typename ConstructibleStringType>
3728#ifdef __INTEL_COMPILER
3729 using laundered_type =
decltype(std::declval<ConstructibleStringType>());
3741template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3744template<
typename BasicJsonType,
typename CompatibleArrayType>
3746 BasicJsonType, CompatibleArrayType,
3749 is_iterator_traits<iterator_traits<detected_t<iterator_t, CompatibleArrayType>>>::value&&
3752 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>::value >>
3759template<
typename BasicJsonType,
typename CompatibleArrayType>
3763template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3766template<
typename BasicJsonType,
typename ConstructibleArrayType>
3768 BasicJsonType, ConstructibleArrayType,
3770 typename BasicJsonType::value_type>::value >>
3771 : std::true_type {};
3773template<
typename BasicJsonType,
typename ConstructibleArrayType>
3775 BasicJsonType, ConstructibleArrayType,
3777 typename BasicJsonType::value_type>::value&&
3780(std::is_move_assignable<ConstructibleArrayType>::value ||
3781 std::is_copy_assignable<ConstructibleArrayType>::value)&&
3782is_detected<iterator_t, ConstructibleArrayType>::value&&
3783is_iterator_traits<iterator_traits<detected_t<iterator_t, ConstructibleArrayType>>>::value&&
3784is_detected<range_value_t, ConstructibleArrayType>::value&&
3787!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>::value&&
3789 detected_t<range_value_t, ConstructibleArrayType >>::value >>
3795 typename BasicJsonType::array_t::value_type>::value ||
3803template<
typename BasicJsonType,
typename ConstructibleArrayType>
3807template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3811template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3813 RealIntegerType, CompatibleNumberIntegerType,
3815 std::is_integral<CompatibleNumberIntegerType>::value&&
3816 !std::is_same<bool, CompatibleNumberIntegerType>::value >>
3824 CompatibleNumberIntegerType>::value &&
3825 CompatibleLimits::is_integer &&
3826 RealLimits::is_signed == CompatibleLimits::is_signed;
3829template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3832 CompatibleNumberIntegerType> {};
3834template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3837template<
typename BasicJsonType,
typename CompatibleType>
3839 BasicJsonType, CompatibleType,
3846template<
typename BasicJsonType,
typename CompatibleType>
3850template<
typename T1,
typename T2>
3853template<
typename T1,
typename... Args>
3856template<
typename BasicJsonType,
typename T>
3859template<
typename BasicJsonType>
3862template<
typename BasicJsonType>
3867template<
template <
typename...>
class Primary,
typename T>
3870template<
template <
typename...>
class Primary,
typename... Args>
3877template<
typename Compare,
typename A,
typename B,
typename =
void>
3880template<
typename Compare,
typename A,
typename B>
3882decltype(
std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
3883decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
3884>> : std::true_type {};
3891template<
typename Comparator,
typename ObjectKeyType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
3895 && !(ExcludeObjectKeyType && std::is_same<KeyType,
3896 ObjectKeyType>::value)
3897 && (!RequireTransparentComparator
3901 std::false_type >::type;
3909template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
3913 typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
3914 RequireTransparentComparator, ExcludeObjectKeyType>::value
3917 std::false_type >::type;
3919template<
typename ObjectType,
typename KeyType>
3923template<
typename BasicJsonType,
typename KeyType>
3927 typename BasicJsonType::object_t, KeyType >::value,
3929 std::false_type >::type;
3933template <
typename T>
3943 template <
typename C>
static one test(
decltype(&C::capacity) ) ;
3946 enum {
value =
sizeof(test<T>(
nullptr)) ==
sizeof(
char) };
3950template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
3953 return static_cast<T
>(
value);
3956template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
3962template<
typename... Types>
3965template<
typename... Types>
3968template<
typename... Types>
3972template<
typename... Types>
3976template<
typename OfType,
typename T>
3978 (std::is_signed<OfType>::value && (
sizeof(T) <
sizeof(OfType)))
3981template<
typename OfType,
typename T,
3982 bool OfTypeSigned = std::is_signed<OfType>::value,
3983 bool TSigned = std::is_signed<T>::value>
3986template<
typename OfType,
typename T>
3991 using CommonType =
typename std::common_type<OfType, T>::type;
3992 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
3996template<
typename OfType,
typename T>
4001 using CommonType =
typename std::common_type<OfType, T>::type;
4002 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4006template<
typename OfType,
typename T>
4011 using CommonType =
typename std::common_type<OfType, T>::type;
4012 return val >= 0 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4017template<
typename OfType,
typename T>
4022 using CommonType =
typename std::common_type<OfType, T>::type;
4023 return static_cast<CommonType
>(val) >=
static_cast<CommonType
>((std::numeric_limits<OfType>::min)())
4024 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4028template<
typename OfType,
typename T,
4029 bool NeverOutOfRange = never_out_of_range<OfType, T>::value,
4033template<
typename OfType,
typename T>
4042template<
typename OfType,
typename T>
4051template<
typename OfType,
typename T>
4089template<
typename... Args>
4090inline std::size_t
concat_length(
const char* cstr, Args&& ... rest);
4092template<
typename StringType,
typename... Args>
4093inline std::size_t
concat_length(
const StringType& str, Args&& ... rest);
4095template<
typename... Args>
4101template<
typename... Args>
4105 return ::strlen(cstr) +
concat_length(std::forward<Args>(rest)...);
4108template<
typename StringType,
typename... Args>
4111 return str.size() +
concat_length(std::forward<Args>(rest)...);
4114template<
typename OutStringType>
4118template<
typename StringType,
typename Arg>
4121template<
typename StringType,
typename Arg>
4124template<
typename StringType,
typename Arg>
4127template<
typename StringType,
typename Arg>
4130template<
typename StringType,
typename Arg>
4131using string_can_append_iter =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().begin(), std::declval<const Arg&>().end()));
4133template<
typename StringType,
typename Arg>
4136template<
typename StringType,
typename Arg>
4137using string_can_append_data =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().data(), std::declval<const Arg&>().size()));
4139template<
typename StringType,
typename Arg>
4142template <
typename OutStringType,
typename Arg,
typename... Args,
4145inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest);
4147template <
typename OutStringType,
typename Arg,
typename... Args,
4151inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4153template <
typename OutStringType,
typename Arg,
typename... Args,
4158inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4160template<
typename OutStringType,
typename Arg,
typename... Args,
4162inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest)
4164 out.append(std::forward<Arg>(arg));
4168template <
typename OutStringType,
typename Arg,
typename... Args,
4169 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4170 && detect_string_can_append_op<OutStringType, Arg>::value,
int > >
4171inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
4173 out += std::forward<Arg>(arg);
4177template <
typename OutStringType,
typename Arg,
typename... Args,
4178 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4179 && !detect_string_can_append_op<OutStringType, Arg>::value
4180 && detect_string_can_append_iter<OutStringType, Arg>::value,
int > >
4181inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4183 out.append(arg.begin(), arg.end());
4187template <
typename OutStringType,
typename Arg,
typename... Args,
4188 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4189 && !detect_string_can_append_op<OutStringType, Arg>::value
4190 && !detect_string_can_append_iter<OutStringType, Arg>::value
4191 && detect_string_can_append_data<OutStringType, Arg>::value,
int > >
4192inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4194 out.append(arg.data(), arg.size());
4198template<
typename OutStringType = std::string,
typename... Args>
4226 const char*
what() const noexcept
override
4236 exception(
int id_, const
char* what_arg) :
id(id_),
m(what_arg) {}
4238 static std::string
name(
const std::string& ename,
int id_)
4248 template<
typename BasicJsonType>
4252 std::vector<std::string> tokens;
4253 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
4255 switch (current->m_parent->type())
4259 for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i)
4261 if (¤t->m_parent->m_value.array->operator[](i) == current)
4272 for (
const auto& element : *current->m_parent->m_value.object)
4274 if (&element.second == current)
4276 tokens.emplace_back(element.first.c_str());
4301 auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
4302 [](
const std::string & a,
const std::string & b)
4304 return concat(a,
'/', detail::escape(b));
4306 return concat(
'(', str,
") ");
4308 static_cast<void>(leaf_element);
4315 std::runtime_error
m;
4332 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4340 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4341 static parse_error create(
int id_, std::size_t byte_,
const std::string& what_arg, BasicJsonContext context)
4346 return {id_, byte_, w.c_str()};
4376 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4380 return {id_, w.c_str()};
4394 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4398 return {id_, w.c_str()};
4411 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4415 return {id_, w.c_str()};
4428 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4432 return {id_, w.c_str()};
4485#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4486#include <experimental/filesystem>
4490namespace std_fs = std::experimental::filesystem;
4493#elif JSON_HAS_FILESYSTEM
4494#include <filesystem>
4498namespace std_fs = std::filesystem;
4514template<
typename BasicJsonType>
4515inline void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
4525template <
typename BasicJsonType,
typename ArithmeticType,
4526 enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
4527 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4531 switch (
static_cast<value_t>(j))
4535 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4540 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4545 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4561template<
typename BasicJsonType>
4562inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
4568 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4571template<
typename BasicJsonType>
4572inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
4578 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4582 typename BasicJsonType,
typename StringType,
4584 std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
4585 && is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value
4586 && !std::is_same<typename BasicJsonType::string_t, StringType>::value
4587 && !is_json_ref<StringType>::value,
int > = 0 >
4595 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4598template<
typename BasicJsonType>
4599inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
4604template<
typename BasicJsonType>
4605inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
4610template<
typename BasicJsonType>
4611inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
4616#if !JSON_DISABLE_ENUM_SERIALIZATION
4617template<
typename BasicJsonType,
typename EnumType,
4618 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4621 typename std::underlying_type<EnumType>::type val;
4623 e =
static_cast<EnumType
>(val);
4628template<
typename BasicJsonType,
typename T,
typename Allocator,
4629 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4630inline void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
4637 std::transform(j.rbegin(), j.rend(),
4638 std::front_inserter(l), [](
const BasicJsonType & i)
4640 return i.template get<T>();
4645template<
typename BasicJsonType,
typename T,
4646 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4647inline void from_json(
const BasicJsonType& j, std::valarray<T>& l)
4654 std::transform(j.begin(), j.end(), std::begin(l),
4655 [](
const BasicJsonType & elem)
4657 return elem.template get<T>();
4661template<
typename BasicJsonType,
typename T, std::
size_t N>
4663->
decltype(j.template get<T>(), void())
4665 for (std::size_t i = 0; i < N; ++i)
4667 arr[i] = j.at(i).template get<T>();
4671template<
typename BasicJsonType>
4674 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
4677template<
typename BasicJsonType,
typename T, std::
size_t N>
4680->
decltype(j.template get<T>(), void())
4682 for (std::size_t i = 0; i < N; ++i)
4684 arr[i] = j.at(i).template get<T>();
4688template<
typename BasicJsonType,
typename ConstructibleArrayType,
4690 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4694 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4695 j.template get<typename ConstructibleArrayType::value_type>(),
4700 ConstructibleArrayType ret;
4701 ret.reserve(j.size());
4702 std::transform(j.begin(), j.end(),
4703 std::inserter(ret, end(ret)), [](
const BasicJsonType & i)
4707 return i.template get<typename ConstructibleArrayType::value_type>();
4709 arr = std::move(ret);
4712template<
typename BasicJsonType,
typename ConstructibleArrayType,
4714 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4721 ConstructibleArrayType ret;
4723 j.begin(), j.end(), std::inserter(ret, end(ret)),
4724 [](
const BasicJsonType & i)
4728 return i.template get<typename ConstructibleArrayType::value_type>();
4730 arr = std::move(ret);
4733template <
typename BasicJsonType,
typename ConstructibleArrayType,
4735 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
4736 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
4738 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
4739 !is_basic_json<ConstructibleArrayType>::value,
4741auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
4743j.template get<typename ConstructibleArrayType::value_type>(),
4754template <
typename BasicJsonType,
typename T, std::size_t... Idx >
4758 return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
4761template <
typename BasicJsonType,
typename T, std::
size_t N >
4773template<
typename BasicJsonType>
4774inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
4781 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
4784template<
typename BasicJsonType,
typename ConstructibleObjectType,
4785 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
4786inline void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
4793 ConstructibleObjectType ret;
4794 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
4795 using value_type =
typename ConstructibleObjectType::value_type;
4797 inner_object->begin(), inner_object->end(),
4798 std::inserter(ret, ret.begin()),
4799 [](
typename BasicJsonType::object_t::value_type
const & p)
4801 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
4803 obj = std::move(ret);
4810template <
typename BasicJsonType,
typename ArithmeticType,
4812 std::is_arithmetic<ArithmeticType>::value&&
4813 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
4814 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
4815 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
4816 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4818inline void from_json(
const BasicJsonType& j, ArithmeticType& val)
4820 switch (
static_cast<value_t>(j))
4824 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4829 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4834 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4839 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
4854template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
4857 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
4860template <
typename BasicJsonType,
class A1,
class A2 >
4863 return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
4864 std::forward<BasicJsonType>(j).at(1).template get<A2>()};
4867template<
typename BasicJsonType,
typename A1,
typename A2>
4873template<
typename BasicJsonType,
typename... Args>
4879template<
typename BasicJsonType,
typename... Args>
4885template<
typename BasicJsonType,
typename TupleRelated>
4894 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
4897template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
4899 typename BasicJsonType::string_t, Key >::value >>
4900inline void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
4907 for (
const auto& p : j)
4913 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4917template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
4919 typename BasicJsonType::string_t, Key >::value >>
4920inline void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
4927 for (
const auto& p : j)
4933 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4937#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
4938template<
typename BasicJsonType>
4939inline void from_json(
const BasicJsonType& j, std_fs::path& p)
4945 p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4951 template<
typename BasicJsonType,
typename T>
4953 noexcept(
noexcept(
from_json(j, std::forward<T>(val))))
4954 ->
decltype(
from_json(j, std::forward<T>(val)))
4956 return from_json(j, std::forward<T>(val));
4962#ifndef JSON_HAS_CPP_17
4971#ifndef JSON_HAS_CPP_17
4992#include <type_traits>
5029template<
typename string_type>
5044 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().
key() ) >::type >::type;
5061 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5071 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5074 noexcept(
std::is_nothrow_move_assignable<IteratorType>::
value
5118 switch (
anchor.m_object->type())
5150 typename IteratorType::reference
value()
const
5192template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
5193auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.key())
5200template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
5201auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.value())
5216#if defined(__clang__)
5218 #pragma clang diagnostic push
5219 #pragma clang diagnostic ignored "-Wmismatched-tags"
5221template<
typename IteratorType>
5222class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
5223 :
public std::integral_constant<std::size_t, 2> {};
5225template<std::
size_t N,
typename IteratorType>
5226class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
5230 get<N>(std::declval <
5231 ::nlohmann::detail::iteration_proxy_value<IteratorType >> ()));
5233#if defined(__clang__)
5234 #pragma clang diagnostic pop
5240 template <
typename IteratorType>
5241 inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy<IteratorType>> =
true;
5275 template<
typename BasicJsonType>
5276 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b)
noexcept
5278 j.m_value.destroy(j.m_type);
5281 j.assert_invariant();
5288 template<
typename BasicJsonType>
5289 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
5291 j.m_value.destroy(j.m_type);
5294 j.assert_invariant();
5297 template<
typename BasicJsonType>
5298 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5300 j.m_value.destroy(j.m_type);
5302 j.m_value = std::move(s);
5303 j.assert_invariant();
5306 template <
typename BasicJsonType,
typename CompatibleStringType,
5309 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
5311 j.m_value.destroy(j.m_type);
5313 j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
5314 j.assert_invariant();
5321 template<
typename BasicJsonType>
5322 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
5324 j.m_value.destroy(j.m_type);
5326 j.m_value =
typename BasicJsonType::binary_t(b);
5327 j.assert_invariant();
5330 template<
typename BasicJsonType>
5331 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
5333 j.m_value.destroy(j.m_type);
5335 j.m_value =
typename BasicJsonType::binary_t(std::move(b));
5336 j.assert_invariant();
5343 template<
typename BasicJsonType>
5344 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val)
noexcept
5346 j.m_value.destroy(j.m_type);
5349 j.assert_invariant();
5356 template<
typename BasicJsonType>
5357 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val)
noexcept
5359 j.m_value.destroy(j.m_type);
5362 j.assert_invariant();
5369 template<
typename BasicJsonType>
5370 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val)
noexcept
5372 j.m_value.destroy(j.m_type);
5375 j.assert_invariant();
5382 template<
typename BasicJsonType>
5383 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
5385 j.m_value.destroy(j.m_type);
5389 j.assert_invariant();
5392 template<
typename BasicJsonType>
5393 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5395 j.m_value.destroy(j.m_type);
5397 j.m_value = std::move(arr);
5399 j.assert_invariant();
5402 template <
typename BasicJsonType,
typename CompatibleArrayType,
5405 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
5410 j.m_value.destroy(j.m_type);
5412 j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
5414 j.assert_invariant();
5417 template<
typename BasicJsonType>
5418 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
5420 j.m_value.destroy(j.m_type);
5423 j.m_value.array->reserve(arr.size());
5424 for (
const bool x : arr)
5426 j.m_value.array->push_back(x);
5427 j.set_parent(j.m_value.array->back());
5429 j.assert_invariant();
5432 template<
typename BasicJsonType,
typename T,
5434 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
5436 j.m_value.destroy(j.m_type);
5439 j.m_value.array->resize(arr.size());
5442 std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
5445 j.assert_invariant();
5452 template<
typename BasicJsonType>
5453 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
5455 j.m_value.destroy(j.m_type);
5459 j.assert_invariant();
5462 template<
typename BasicJsonType>
5463 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5465 j.m_value.destroy(j.m_type);
5467 j.m_value = std::move(obj);
5469 j.assert_invariant();
5472 template <
typename BasicJsonType,
typename CompatibleObjectType,
5474 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
5479 j.m_value.destroy(j.m_type);
5481 j.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
5483 j.assert_invariant();
5491template<
typename BasicJsonType,
typename T,
5492 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value,
int> = 0>
5493inline void to_json(BasicJsonType& j, T b)
noexcept
5498template<
typename BasicJsonType,
5499 enable_if_t<std::is_convertible<const std::vector<bool>::reference&,
typename BasicJsonType::boolean_t>::value,
int> = 0>
5500inline void to_json(BasicJsonType& j,
const std::vector<bool>::reference& b)
noexcept
5505template<
typename BasicJsonType,
typename CompatibleString,
5506 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
5507inline void to_json(BasicJsonType& j,
const CompatibleString& s)
5512template<
typename BasicJsonType>
5513inline void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5518template<
typename BasicJsonType,
typename FloatType,
5519 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
5520inline void to_json(BasicJsonType& j, FloatType val)
noexcept
5525template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
5526 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
5527inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val)
noexcept
5532template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
5533 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
5534inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val)
noexcept
5539#if !JSON_DISABLE_ENUM_SERIALIZATION
5540template<
typename BasicJsonType,
typename EnumType,
5541 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
5542inline void to_json(BasicJsonType& j, EnumType e)
noexcept
5544 using underlying_type =
typename std::underlying_type<EnumType>::type;
5549template<
typename BasicJsonType>
5550inline void to_json(BasicJsonType& j,
const std::vector<bool>& e)
5555template <
typename BasicJsonType,
typename CompatibleArrayType,
5556 enable_if_t < is_compatible_array_type<BasicJsonType,
5557 CompatibleArrayType>::value&&
5558 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
5560 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
5561 !is_basic_json<CompatibleArrayType>::value,
5563inline void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
5568template<
typename BasicJsonType>
5569inline void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
5574template<
typename BasicJsonType,
typename T,
5575 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
5576inline void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
5581template<
typename BasicJsonType>
5582inline void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5587template <
typename BasicJsonType,
typename CompatibleObjectType,
5588 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
5589inline void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
5594template<
typename BasicJsonType>
5595inline void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5601 typename BasicJsonType,
typename T, std::size_t N,
5602 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
5603 const T(&)[N]>::value,
5605inline void to_json(BasicJsonType& j,
const T(&arr)[N])
5610template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
5611inline void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
5613 j = { p.first, p.second };
5617template<
typename BasicJsonType,
typename T,
5618 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value,
int> = 0>
5621 j = { {b.key(), b.value()} };
5624template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
5627 j = { std::get<Idx>(t)... };
5630template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
5631inline void to_json(BasicJsonType& j,
const T& t)
5636#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5637template<
typename BasicJsonType>
5638inline void to_json(BasicJsonType& j,
const std_fs::path& p)
5646 template<
typename BasicJsonType,
typename T>
5647 auto operator()(BasicJsonType& j, T&& val)
const noexcept(
noexcept(
to_json(j, std::forward<T>(val))))
5648 ->
decltype(
to_json(j, std::forward<T>(val)), void())
5650 return to_json(j, std::forward<T>(val));
5655#ifndef JSON_HAS_CPP_17
5664#ifndef JSON_HAS_CPP_17
5676template<
typename ValueType,
typename>
5681 template<
typename BasicJsonType,
typename TargetType = ValueType>
5682 static auto from_json(BasicJsonType && j, TargetType& val)
noexcept(
5691 template<
typename BasicJsonType,
typename TargetType = ValueType>
5701 template<
typename BasicJsonType,
typename TargetType = ValueType>
5702 static auto to_json(BasicJsonType& j, TargetType && val)
noexcept(
5734template<
typename BinaryType>
5778 return !(rhs == *
this);
5837#include <functional>
5849inline std::size_t
combine(std::size_t seed, std::size_t h)
noexcept
5851 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
5866template<
typename BasicJsonType>
5867std::size_t
hash(
const BasicJsonType& j)
5869 using string_t =
typename BasicJsonType::string_t;
5870 using number_integer_t =
typename BasicJsonType::number_integer_t;
5871 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
5872 using number_float_t =
typename BasicJsonType::number_float_t;
5874 const auto type =
static_cast<std::size_t
>(j.type());
5877 case BasicJsonType::value_t::null:
5878 case BasicJsonType::value_t::discarded:
5883 case BasicJsonType::value_t::object:
5885 auto seed =
combine(type, j.size());
5886 for (
const auto& element : j.items())
5888 const auto h = std::hash<string_t> {}(element.key());
5895 case BasicJsonType::value_t::array:
5897 auto seed =
combine(type, j.size());
5898 for (
const auto& element : j)
5905 case BasicJsonType::value_t::string:
5907 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
5911 case BasicJsonType::value_t::boolean:
5913 const auto h = std::hash<bool> {}(j.template get<bool>());
5917 case BasicJsonType::value_t::number_integer:
5919 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
5923 case BasicJsonType::value_t::number_unsigned:
5925 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
5929 case BasicJsonType::value_t::number_float:
5931 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
5935 case BasicJsonType::value_t::binary:
5937 auto seed =
combine(type, j.get_binary().size());
5938 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
5940 seed =
combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
5941 for (
const auto byte : j.get_binary())
5943 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
6002#include <type_traits>
6052 return std::fgetc(
m_file);
6081 is->clear(
is->rdstate() & std::ios::eofbit);
6086 :
is(&i),
sb(i.rdbuf())
6095 :
is(rhs.is),
sb(rhs.sb)
6106 auto res =
sb->sbumpc();
6110 is->clear(
is->rdstate() | std::ios::eofbit);
6117 std::istream*
is =
nullptr;
6118 std::streambuf*
sb =
nullptr;
6124template<
typename IteratorType>
6128 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
6138 auto result = std::char_traits<char_type>::to_int_type(*
current);
6143 return std::char_traits<char_type>::eof();
6150 template<
typename BaseInputAdapter,
size_t T>
6160template<
typename BaseInputAdapter,
size_t T>
6163template<
typename BaseInputAdapter>
6168 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6169 size_t& utf8_bytes_index,
6170 size_t& utf8_bytes_filled)
6172 utf8_bytes_index = 0;
6176 utf8_bytes[0] = std::char_traits<char>::eof();
6177 utf8_bytes_filled = 1;
6182 const auto wc = input.get_character();
6187 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6188 utf8_bytes_filled = 1;
6190 else if (wc <= 0x7FF)
6192 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
6193 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6194 utf8_bytes_filled = 2;
6196 else if (wc <= 0xFFFF)
6198 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
6199 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6200 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6201 utf8_bytes_filled = 3;
6203 else if (wc <= 0x10FFFF)
6205 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
6206 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
6207 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6208 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6209 utf8_bytes_filled = 4;
6214 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6215 utf8_bytes_filled = 1;
6221template<
typename BaseInputAdapter>
6226 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6227 size_t& utf8_bytes_index,
6228 size_t& utf8_bytes_filled)
6230 utf8_bytes_index = 0;
6234 utf8_bytes[0] = std::char_traits<char>::eof();
6235 utf8_bytes_filled = 1;
6240 const auto wc = input.get_character();
6245 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6246 utf8_bytes_filled = 1;
6248 else if (wc <= 0x7FF)
6250 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
6251 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6252 utf8_bytes_filled = 2;
6254 else if (0xD800 > wc || wc >= 0xE000)
6256 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
6257 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6258 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6259 utf8_bytes_filled = 3;
6265 const auto wc2 =
static_cast<unsigned int>(input.get_character());
6266 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
6267 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
6268 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
6269 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
6270 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
6271 utf8_bytes_filled = 4;
6275 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6276 utf8_bytes_filled = 1;
6284template<
typename BaseInputAdapter,
typename W
ideCharType>
6298 fill_buffer<sizeof(WideCharType)>();
6320 std::array<std::char_traits<char>::int_type, 4>
utf8_bytes = {{0, 0, 0, 0}};
6329template<
typename IteratorType,
typename Enable =
void>
6333 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6338 return adapter_type(std::move(first), std::move(last));
6352template<
typename IteratorType>
6356 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6367template<
typename IteratorType>
6371 return factory_type::create(first, last);
6378namespace container_input_adapter_factory_impl
6384template<
typename ContainerType,
typename Enable =
void>
6387template<
typename ContainerType>
6389 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
6401template<
typename ContainerType>
6428template <
typename CharT,
6429 typename std::enable_if <
6430 std::is_pointer<CharT>::value&&
6431 !std::is_array<CharT>::value&&
6432 std::is_integral<typename std::remove_pointer<CharT>::type>::value&&
6433 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6437 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
6438 const auto* ptr =
reinterpret_cast<const char*
>(b);
6442template<
typename T, std::
size_t N>
6454 template <
typename CharT,
6455 typename std::enable_if <
6456 std::is_pointer<CharT>::value&&
6457 std::is_integral<typename std::remove_pointer<CharT>::type>::value&&
6458 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6461 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) + l) {}
6463 template<
class IteratorType,
6464 typename std::enable_if<
6465 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value,
6472 return std::move(ia);
6515template<
typename BasicJsonType>
6619 const std::string& last_token,
6646template<
typename BasicJsonType>
6662 : root(r), allow_exceptions(allow_exceptions_)
6674 handle_value(
nullptr);
6710 handle_value(std::move(val));
6716 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
6718 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6732 object_element = &(ref_stack.back()->m_value.object->operator[](val));
6741 ref_stack.back()->set_parents();
6742 ref_stack.pop_back();
6748 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
6750 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6763 ref_stack.back()->set_parents();
6764 ref_stack.pop_back();
6768 template<
class Exception>
6770 const Exception& ex)
6773 static_cast<void>(ex);
6774 if (allow_exceptions)
6793 template<
typename Value>
6797 if (ref_stack.empty())
6799 root = BasicJsonType(std::forward<Value>(v));
6803 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6805 if (ref_stack.back()->is_array())
6807 ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
6808 return &(ref_stack.back()->m_value.array->back());
6813 *object_element = BasicJsonType(std::forward<Value>(v));
6814 return object_element;
6820 std::vector<BasicJsonType*> ref_stack {};
6822 BasicJsonType* object_element =
nullptr;
6824 bool errored =
false;
6826 const bool allow_exceptions =
true;
6829template<
typename BasicJsonType>
6843 const bool allow_exceptions_ =
true)
6844 : root(r), callback(cb), allow_exceptions(allow_exceptions_)
6846 keep_stack.push_back(
true);
6858 handle_value(
nullptr);
6894 handle_value(std::move(val));
6901 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::object_start,
discarded);
6902 keep_stack.push_back(keep);
6904 auto val = handle_value(BasicJsonType::value_t::object,
true);
6905 ref_stack.push_back(val.second);
6908 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6918 BasicJsonType k = BasicJsonType(val);
6921 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::key, k);
6922 key_keep_stack.push_back(keep);
6925 if (keep && ref_stack.back())
6927 object_element = &(ref_stack.back()->m_value.object->operator[](val) =
discarded);
6935 if (ref_stack.back())
6937 if (!callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
6944 ref_stack.back()->set_parents();
6950 ref_stack.pop_back();
6951 keep_stack.pop_back();
6953 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
6956 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
6958 if (it->is_discarded())
6960 ref_stack.back()->erase(it);
6971 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::array_start,
discarded);
6972 keep_stack.push_back(keep);
6974 auto val = handle_value(BasicJsonType::value_t::array,
true);
6975 ref_stack.push_back(val.second);
6978 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6990 if (ref_stack.back())
6992 keep = callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
6995 ref_stack.back()->set_parents();
7006 ref_stack.pop_back();
7007 keep_stack.pop_back();
7010 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
7012 ref_stack.back()->m_value.array->pop_back();
7018 template<
class Exception>
7020 const Exception& ex)
7023 static_cast<void>(ex);
7024 if (allow_exceptions)
7052 template<
typename Value>
7053 std::pair<bool, BasicJsonType*>
handle_value(Value&& v,
const bool skip_callback =
false)
7059 if (!keep_stack.back())
7061 return {
false,
nullptr};
7065 auto value = BasicJsonType(std::forward<Value>(v));
7068 const bool keep = skip_callback || callback(
static_cast<int>(ref_stack.size()), parse_event_t::value,
value);
7073 return {
false,
nullptr};
7076 if (ref_stack.empty())
7078 root = std::move(
value);
7079 return {
true, &root};
7084 if (!ref_stack.back())
7086 return {
false,
nullptr};
7090 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
7093 if (ref_stack.back()->is_array())
7095 ref_stack.back()->m_value.array->emplace_back(std::move(
value));
7096 return {
true, &(ref_stack.back()->m_value.array->back())};
7103 const bool store_element = key_keep_stack.back();
7104 key_keep_stack.pop_back();
7108 return {
false,
nullptr};
7112 *object_element = std::move(
value);
7113 return {
true, object_element};
7119 std::vector<BasicJsonType*> ref_stack {};
7121 std::vector<bool> keep_stack {};
7123 std::vector<bool> key_keep_stack {};
7125 BasicJsonType* object_element =
nullptr;
7127 bool errored =
false;
7131 const bool allow_exceptions =
true;
7133 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
7136template<
typename BasicJsonType>
7231#include <initializer_list>
7251template<
typename BasicJsonType>
7284 case token_type::uninitialized:
7285 return "<uninitialized>";
7286 case token_type::literal_true:
7287 return "true literal";
7288 case token_type::literal_false:
7289 return "false literal";
7290 case token_type::literal_null:
7291 return "null literal";
7292 case token_type::value_string:
7293 return "string literal";
7294 case token_type::value_unsigned:
7295 case token_type::value_integer:
7296 case token_type::value_float:
7297 return "number literal";
7298 case token_type::begin_array:
7300 case token_type::begin_object:
7302 case token_type::end_array:
7304 case token_type::end_object:
7306 case token_type::name_separator:
7308 case token_type::value_separator:
7310 case token_type::parse_error:
7311 return "<parse error>";
7312 case token_type::end_of_input:
7313 return "end of input";
7314 case token_type::literal_or_value:
7315 return "'[', '{', or a literal";
7318 return "unknown token";
7328template<
typename BasicJsonType,
typename InputAdapterType>
7341 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
7342 : ia(
std::move(adapter))
7343 , ignore_comments(ignore_comments_)
7344 , decimal_point_char(static_cast<
char_int_type>(get_decimal_point()))
7363 const auto* loc = localeconv();
7365 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
7393 const auto factors = { 12u, 8u, 4u, 0u };
7394 for (
const auto factor : factors)
7398 if (current >=
'0' && current <=
'9')
7400 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x30u) << factor);
7402 else if (current >=
'A' && current <=
'F')
7404 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x37u) << factor);
7406 else if (current >=
'a' && current <=
'f')
7408 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x57u) << factor);
7416 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
7437 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
7440 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
7449 error_message =
"invalid string: ill-formed UTF-8 byte";
7486 case std::char_traits<char_type>::eof():
7488 error_message =
"invalid string: missing closing quote";
7489 return token_type::parse_error;
7495 return token_type::value_string;
7539 const int codepoint1 = get_codepoint();
7540 int codepoint = codepoint1;
7544 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7545 return token_type::parse_error;
7549 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
7554 const int codepoint2 = get_codepoint();
7558 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7559 return token_type::parse_error;
7566 codepoint =
static_cast<int>(
7568 (
static_cast<unsigned int>(codepoint1) << 10u)
7570 +
static_cast<unsigned int>(codepoint2)
7578 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7579 return token_type::parse_error;
7584 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7585 return token_type::parse_error;
7592 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
7593 return token_type::parse_error;
7598 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7601 if (codepoint < 0x80)
7606 else if (codepoint <= 0x7FF)
7609 add(
static_cast<char_int_type>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
7610 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7612 else if (codepoint <= 0xFFFF)
7615 add(
static_cast<char_int_type>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
7616 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7617 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7622 add(
static_cast<char_int_type>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
7623 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7624 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7625 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7633 error_message =
"invalid string: forbidden character after backslash";
7634 return token_type::parse_error;
7643 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7644 return token_type::parse_error;
7649 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7650 return token_type::parse_error;
7655 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7656 return token_type::parse_error;
7661 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7662 return token_type::parse_error;
7667 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7668 return token_type::parse_error;
7673 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7674 return token_type::parse_error;
7679 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7680 return token_type::parse_error;
7685 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7686 return token_type::parse_error;
7691 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7692 return token_type::parse_error;
7697 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7698 return token_type::parse_error;
7703 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
7704 return token_type::parse_error;
7709 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
7710 return token_type::parse_error;
7715 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7716 return token_type::parse_error;
7721 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7722 return token_type::parse_error;
7727 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
7728 return token_type::parse_error;
7733 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
7734 return token_type::parse_error;
7739 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7740 return token_type::parse_error;
7745 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7746 return token_type::parse_error;
7751 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
7752 return token_type::parse_error;
7757 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
7758 return token_type::parse_error;
7763 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
7764 return token_type::parse_error;
7769 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
7770 return token_type::parse_error;
7775 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
7776 return token_type::parse_error;
7781 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
7782 return token_type::parse_error;
7787 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
7788 return token_type::parse_error;
7793 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
7794 return token_type::parse_error;
7799 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
7800 return token_type::parse_error;
7805 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7806 return token_type::parse_error;
7811 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
7812 return token_type::parse_error;
7817 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7818 return token_type::parse_error;
7823 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7824 return token_type::parse_error;
7829 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7830 return token_type::parse_error;
7967 return token_type::parse_error;
7977 return token_type::parse_error;
8001 return token_type::parse_error;
8011 return token_type::parse_error;
8021 return token_type::parse_error;
8033 return token_type::parse_error;
8043 return token_type::parse_error;
8051 error_message =
"invalid string: ill-formed UTF-8 byte";
8052 return token_type::parse_error;
8075 case std::char_traits<char_type>::eof():
8092 case std::char_traits<char_type>::eof():
8095 error_message =
"invalid comment; missing closing '*/'";
8123 error_message =
"invalid comment; expecting '/' or '*' after '/'";
8130 static
void strtof(
float&
f, const
char* str,
char** endptr) noexcept
8132 f = std::strtof(str, endptr);
8136 static
void strtof(
double&
f, const
char* str,
char** endptr) noexcept
8138 f = std::strtod(str, endptr);
8142 static
void strtof(
long double&
f, const
char* str,
char** endptr) noexcept
8144 f = std::strtold(str, endptr);
8194 token_type number_type = token_type::value_unsigned;
8202 goto scan_number_minus;
8208 goto scan_number_zero;
8222 goto scan_number_any1;
8232 number_type = token_type::value_integer;
8238 goto scan_number_zero;
8252 goto scan_number_any1;
8257 error_message =
"invalid number; expected digit after '-'";
8258 return token_type::parse_error;
8268 add(decimal_point_char);
8269 goto scan_number_decimal1;
8276 goto scan_number_exponent;
8280 goto scan_number_done;
8299 goto scan_number_any1;
8304 add(decimal_point_char);
8305 goto scan_number_decimal1;
8312 goto scan_number_exponent;
8316 goto scan_number_done;
8319scan_number_decimal1:
8321 number_type = token_type::value_float;
8336 goto scan_number_decimal2;
8341 error_message =
"invalid number; expected digit after '.'";
8342 return token_type::parse_error;
8346scan_number_decimal2:
8362 goto scan_number_decimal2;
8369 goto scan_number_exponent;
8373 goto scan_number_done;
8376scan_number_exponent:
8378 number_type = token_type::value_float;
8385 goto scan_number_sign;
8400 goto scan_number_any2;
8406 "invalid number; expected '+', '-', or digit after exponent";
8407 return token_type::parse_error;
8427 goto scan_number_any2;
8432 error_message =
"invalid number; expected digit after exponent sign";
8433 return token_type::parse_error;
8453 goto scan_number_any2;
8457 goto scan_number_done;
8465 char* endptr =
nullptr;
8469 if (number_type == token_type::value_unsigned)
8471 const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
8474 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8479 if (value_unsigned == x)
8481 return token_type::value_unsigned;
8485 else if (number_type == token_type::value_integer)
8487 const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
8490 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8495 if (value_integer == x)
8497 return token_type::value_integer;
8504 strtof(value_float, token_buffer.data(), &endptr);
8507 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8509 return token_type::value_float;
8521 JSON_ASSERT(std::char_traits<char_type>::to_char_type(current) == literal_text[0]);
8522 for (std::size_t i = 1; i < length; ++i)
8526 error_message =
"invalid literal";
8527 return token_type::parse_error;
8540 token_buffer.clear();
8541 token_string.clear();
8542 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
8557 ++position.chars_read_total;
8558 ++position.chars_read_current_line;
8567 current = ia.get_character();
8572 token_string.push_back(std::char_traits<char_type>::to_char_type(current));
8575 if (current ==
'\n')
8577 ++position.lines_read;
8578 position.chars_read_current_line = 0;
8596 --position.chars_read_total;
8599 if (position.chars_read_current_line == 0)
8601 if (position.lines_read > 0)
8603 --position.lines_read;
8608 --position.chars_read_current_line;
8614 token_string.pop_back();
8621 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
8632 return value_integer;
8638 return value_unsigned;
8650 return token_buffer;
8670 for (
const auto c : token_string)
8672 if (
static_cast<unsigned char>(c) <=
'\x1F')
8675 std::array<char, 9> cs{{}};
8676 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
8677 result += cs.data();
8682 result.push_back(
static_cast<std::string::value_type
>(c));
8693 return error_message;
8709 return get() == 0xBB &&
get() == 0xBF;
8724 while (current ==
' ' || current ==
'\t' || current ==
'\n' || current ==
'\r');
8730 if (position.chars_read_total == 0 && !skip_bom())
8732 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8733 return token_type::parse_error;
8740 while (ignore_comments && current ==
'/')
8742 if (!scan_comment())
8744 return token_type::parse_error;
8755 return token_type::begin_array;
8757 return token_type::end_array;
8759 return token_type::begin_object;
8761 return token_type::end_object;
8763 return token_type::name_separator;
8765 return token_type::value_separator;
8771 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8776 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8781 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8786 return scan_string();
8800 return scan_number();
8805 case std::char_traits<char_type>::eof():
8806 return token_type::end_of_input;
8810 error_message =
"invalid literal";
8811 return token_type::parse_error;
8820 const bool ignore_comments =
false;
8826 bool next_unget =
false;
8832 std::vector<char_type> token_string {};
8838 const char* error_message =
"";
8885 decltype(std::declval<T&>().boolean(std::declval<bool>()));
8887template<
typename T,
typename Integer>
8889 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
8891template<
typename T,
typename Un
signed>
8893 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
8895template<
typename T,
typename Float,
typename String>
8897 std::declval<Float>(), std::declval<const String&>()));
8899template<
typename T,
typename String>
8901 decltype(std::declval<T&>().string(std::declval<String&>()));
8903template<
typename T,
typename Binary>
8905 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
8909 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
8911template<
typename T,
typename String>
8913 decltype(std::declval<T&>().key(std::declval<String&>()));
8920 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
8925template<
typename T,
typename Exception>
8927 std::declval<std::size_t>(), std::declval<const std::string&>(),
8928 std::declval<const Exception&>()));
8930template<
typename SAX,
typename BasicJsonType>
8935 "BasicJsonType must be of type basic_json<...>");
8961template<
typename SAX,
typename BasicJsonType>
8966 "BasicJsonType must be of type basic_json<...>");
8977 "Missing/invalid function: bool null()");
8979 "Missing/invalid function: bool boolean(bool)");
8981 "Missing/invalid function: bool boolean(bool)");
8985 "Missing/invalid function: bool number_integer(number_integer_t)");
8989 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
8992 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
8995 "Missing/invalid function: bool string(string_t&)");
8998 "Missing/invalid function: bool binary(binary_t&)");
9000 "Missing/invalid function: bool start_object(std::size_t)");
9002 "Missing/invalid function: bool key(string_t&)");
9004 "Missing/invalid function: bool end_object()");
9006 "Missing/invalid function: bool start_array(std::size_t)");
9008 "Missing/invalid function: bool end_array()");
9011 "Missing/invalid function: bool parse_error(std::size_t, const "
9012 "std::string&, const exception&)");
9046 return *
reinterpret_cast<char*
>(&num) == 1;
9057template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
9098 const
bool strict = true,
9102 bool result =
false;
9106 case input_format_t::bson:
9107 result = parse_bson_internal();
9110 case input_format_t::cbor:
9111 result = parse_cbor_internal(
true, tag_handler);
9114 case input_format_t::msgpack:
9115 result = parse_msgpack_internal();
9118 case input_format_t::ubjson:
9119 case input_format_t::bjdata:
9120 result = parse_ubjson_internal();
9131 if (input_format == input_format_t::ubjson || input_format == input_format_t::bjdata)
9142 return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read,
9143 exception_message(input_format,
concat(
"expected end of input; last byte: 0x", get_token_string()),
"value"),
nullptr));
9161 std::int32_t document_size{};
9162 get_number<std::int32_t, true>(input_format_t::bson, document_size);
9174 return sax->end_object();
9186 auto out = std::back_inserter(result);
9194 if (current == 0x00)
9198 *out++ =
static_cast<typename string_t::value_type
>(current);
9213 template<
typename NumberType>
9218 auto last_token = get_token_string();
9219 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
9220 exception_message(input_format_t::bson,
concat(
"string length must be at least 1, is ",
std::to_string(len)),
"string"),
nullptr));
9223 return get_string(input_format_t::bson, len -
static_cast<NumberType
>(1), result) &&
get() != std::char_traits<char_type>::eof();
9235 template<
typename NumberType>
9240 auto last_token = get_token_string();
9241 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
9242 exception_message(input_format_t::bson,
concat(
"byte array length cannot be negative, is ",
std::to_string(len)),
"binary"),
nullptr));
9246 std::uint8_t subtype{};
9247 get_number<std::uint8_t>(input_format_t::bson, subtype);
9248 result.set_subtype(subtype);
9250 return get_binary(input_format_t::bson, len, result);
9264 const std::size_t element_type_parse_position)
9266 switch (element_type)
9271 return get_number<double, true>(input_format_t::bson, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
9278 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_string(len,
value) && sax->string(
value);
9283 return parse_bson_internal();
9288 return parse_bson_array();
9295 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_binary(len,
value) && sax->binary(
value);
9300 return sax->boolean(
get() != 0);
9310 std::int32_t
value{};
9311 return get_number<std::int32_t, true>(input_format_t::bson,
value) && sax->number_integer(
value);
9316 std::int64_t
value{};
9317 return get_number<std::int64_t, true>(input_format_t::bson,
value) && sax->number_integer(
value);
9322 std::array<char, 3> cr{{}};
9323 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
9324 std::string cr_str{cr.data()};
9325 return sax->parse_error(element_type_parse_position, cr_str,
9326 parse_error::create(114, element_type_parse_position,
concat(
"Unsupported BSON record type 0x", cr_str),
nullptr));
9347 while (
auto element_type =
get())
9354 const std::size_t element_type_parse_position = chars_read;
9360 if (!is_array && !sax->key(
key))
9365 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
9383 std::int32_t document_size{};
9384 get_number<std::int32_t, true>(input_format_t::bson, document_size);
9396 return sax->end_array();
9414 switch (get_char ?
get() : current)
9417 case std::char_traits<char_type>::eof():
9418 return unexpect_eof(input_format_t::cbor,
"value");
9449 std::uint8_t number{};
9450 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9455 std::uint16_t number{};
9456 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9461 std::uint32_t number{};
9462 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9467 std::uint64_t number{};
9468 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9496 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 - current));
9500 std::uint8_t number{};
9501 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1) - number);
9506 std::uint16_t number{};
9507 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1) - number);
9512 std::uint32_t number{};
9513 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1) - number);
9518 std::uint64_t number{};
9519 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1)
9555 return get_cbor_binary(b) && sax->binary(b);
9590 return get_cbor_string(s) && sax->string(s);
9618 return get_cbor_array(
9619 conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9624 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9629 std::uint16_t len{};
9630 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9635 std::uint32_t len{};
9636 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
9641 std::uint64_t len{};
9642 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
9646 return get_cbor_array(
static_cast<std::size_t
>(-1), tag_handler);
9673 return get_cbor_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9678 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9683 std::uint16_t len{};
9684 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9689 std::uint32_t len{};
9690 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
9695 std::uint64_t len{};
9696 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
9700 return get_cbor_object(
static_cast<std::size_t
>(-1), tag_handler);
9722 switch (tag_handler)
9724 case cbor_tag_handler_t::error:
9726 auto last_token = get_token_string();
9727 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
9728 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
9731 case cbor_tag_handler_t::ignore:
9738 std::uint8_t subtype_to_ignore{};
9739 get_number(input_format_t::cbor, subtype_to_ignore);
9744 std::uint16_t subtype_to_ignore{};
9745 get_number(input_format_t::cbor, subtype_to_ignore);
9750 std::uint32_t subtype_to_ignore{};
9751 get_number(input_format_t::cbor, subtype_to_ignore);
9756 std::uint64_t subtype_to_ignore{};
9757 get_number(input_format_t::cbor, subtype_to_ignore);
9763 return parse_cbor_internal(
true, tag_handler);
9766 case cbor_tag_handler_t::store:
9774 std::uint8_t subtype{};
9775 get_number(input_format_t::cbor, subtype);
9776 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9781 std::uint16_t subtype{};
9782 get_number(input_format_t::cbor, subtype);
9783 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9788 std::uint32_t subtype{};
9789 get_number(input_format_t::cbor, subtype);
9790 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9795 std::uint64_t subtype{};
9796 get_number(input_format_t::cbor, subtype);
9797 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9801 return parse_cbor_internal(
true, tag_handler);
9804 return get_cbor_binary(b) && sax->binary(b);
9814 return sax->boolean(
false);
9817 return sax->boolean(
true);
9824 const auto byte1_raw =
get();
9829 const auto byte2_raw =
get();
9835 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
9836 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
9846 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
9847 const double val = [&half]
9849 const int exp = (half >> 10u) & 0x1Fu;
9850 const unsigned int mant = half & 0x3FFu;
9856 return std::ldexp(mant, -24);
9859 ? std::numeric_limits<double>::infinity()
9860 : std::numeric_limits<double>::quiet_NaN();
9862 return std::ldexp(mant + 1024, exp - 25);
9865 return sax->number_float((half & 0x8000u) != 0
9873 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
9879 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
9884 auto last_token = get_token_string();
9885 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
9886 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
9937 return get_string(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
9943 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
9948 std::uint16_t len{};
9949 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
9954 std::uint32_t len{};
9955 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
9960 std::uint64_t len{};
9961 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
9966 while (
get() != 0xFF)
9969 if (!get_cbor_string(chunk))
9973 result.append(chunk);
9980 auto last_token = get_token_string();
9981 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
9982 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token),
"string"),
nullptr));
10033 return get_binary(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10038 std::uint8_t len{};
10039 return get_number(input_format_t::cbor, len) &&
10040 get_binary(input_format_t::cbor, len, result);
10045 std::uint16_t len{};
10046 return get_number(input_format_t::cbor, len) &&
10047 get_binary(input_format_t::cbor, len, result);
10052 std::uint32_t len{};
10053 return get_number(input_format_t::cbor, len) &&
10054 get_binary(input_format_t::cbor, len, result);
10059 std::uint64_t len{};
10060 return get_number(input_format_t::cbor, len) &&
10061 get_binary(input_format_t::cbor, len, result);
10066 while (
get() != 0xFF)
10069 if (!get_cbor_binary(chunk))
10073 result.insert(result.end(), chunk.begin(), chunk.end());
10080 auto last_token = get_token_string();
10081 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10082 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x", last_token),
"binary"),
nullptr));
10101 if (len !=
static_cast<std::size_t
>(-1))
10103 for (std::size_t i = 0; i < len; ++i)
10113 while (
get() != 0xFF)
10122 return sax->end_array();
10142 if (len !=
static_cast<std::size_t
>(-1))
10144 for (std::size_t i = 0; i < len; ++i)
10161 while (
get() != 0xFF)
10177 return sax->end_object();
10192 case std::char_traits<char_type>::eof():
10193 return unexpect_eof(input_format_t::msgpack,
"value");
10343 return get_msgpack_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
10362 return get_msgpack_array(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
10402 return get_msgpack_string(s) && sax->string(s);
10406 return sax->null();
10409 return sax->boolean(
false);
10412 return sax->boolean(
true);
10427 return get_msgpack_binary(b) && sax->binary(b);
10433 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
10439 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
10444 std::uint8_t number{};
10445 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10450 std::uint16_t number{};
10451 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10456 std::uint32_t number{};
10457 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10462 std::uint64_t number{};
10463 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10468 std::int8_t number{};
10469 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10474 std::int16_t number{};
10475 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10480 std::int32_t number{};
10481 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10486 std::int64_t number{};
10487 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10492 std::uint16_t len{};
10493 return get_number(input_format_t::msgpack, len) && get_msgpack_array(
static_cast<std::size_t
>(len));
10498 std::uint32_t len{};
10499 return get_number(input_format_t::msgpack, len) && get_msgpack_array(conditional_static_cast<std::size_t>(len));
10504 std::uint16_t len{};
10505 return get_number(input_format_t::msgpack, len) && get_msgpack_object(
static_cast<std::size_t
>(len));
10510 std::uint32_t len{};
10511 return get_number(input_format_t::msgpack, len) && get_msgpack_object(conditional_static_cast<std::size_t>(len));
10547 return sax->number_integer(
static_cast<std::int8_t
>(current));
10551 auto last_token = get_token_string();
10552 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10553 exception_message(input_format_t::msgpack,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10611 return get_string(input_format_t::msgpack,
static_cast<unsigned int>(current) & 0x1Fu, result);
10616 std::uint8_t len{};
10617 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
10622 std::uint16_t len{};
10623 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
10628 std::uint32_t len{};
10629 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
10634 auto last_token = get_token_string();
10635 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10636 exception_message(input_format_t::msgpack,
concat(
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token),
"string"),
nullptr));
10654 auto assign_and_return_true = [&result](std::int8_t subtype)
10656 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
10664 std::uint8_t len{};
10665 return get_number(input_format_t::msgpack, len) &&
10666 get_binary(input_format_t::msgpack, len, result);
10671 std::uint16_t len{};
10672 return get_number(input_format_t::msgpack, len) &&
10673 get_binary(input_format_t::msgpack, len, result);
10678 std::uint32_t len{};
10679 return get_number(input_format_t::msgpack, len) &&
10680 get_binary(input_format_t::msgpack, len, result);
10685 std::uint8_t len{};
10686 std::int8_t subtype{};
10687 return get_number(input_format_t::msgpack, len) &&
10688 get_number(input_format_t::msgpack, subtype) &&
10689 get_binary(input_format_t::msgpack, len, result) &&
10690 assign_and_return_true(subtype);
10695 std::uint16_t len{};
10696 std::int8_t subtype{};
10697 return get_number(input_format_t::msgpack, len) &&
10698 get_number(input_format_t::msgpack, subtype) &&
10699 get_binary(input_format_t::msgpack, len, result) &&
10700 assign_and_return_true(subtype);
10705 std::uint32_t len{};
10706 std::int8_t subtype{};
10707 return get_number(input_format_t::msgpack, len) &&
10708 get_number(input_format_t::msgpack, subtype) &&
10709 get_binary(input_format_t::msgpack, len, result) &&
10710 assign_and_return_true(subtype);
10715 std::int8_t subtype{};
10716 return get_number(input_format_t::msgpack, subtype) &&
10717 get_binary(input_format_t::msgpack, 1, result) &&
10718 assign_and_return_true(subtype);
10723 std::int8_t subtype{};
10724 return get_number(input_format_t::msgpack, subtype) &&
10725 get_binary(input_format_t::msgpack, 2, result) &&
10726 assign_and_return_true(subtype);
10731 std::int8_t subtype{};
10732 return get_number(input_format_t::msgpack, subtype) &&
10733 get_binary(input_format_t::msgpack, 4, result) &&
10734 assign_and_return_true(subtype);
10739 std::int8_t subtype{};
10740 return get_number(input_format_t::msgpack, subtype) &&
10741 get_binary(input_format_t::msgpack, 8, result) &&
10742 assign_and_return_true(subtype);
10747 std::int8_t subtype{};
10748 return get_number(input_format_t::msgpack, subtype) &&
10749 get_binary(input_format_t::msgpack, 16, result) &&
10750 assign_and_return_true(subtype);
10769 for (std::size_t i = 0; i < len; ++i)
10777 return sax->end_array();
10792 for (std::size_t i = 0; i < len; ++i)
10807 return sax->end_object();
10823 return get_ubjson_value(get_char ? get_ignore_noop() : current);
10856 std::uint8_t len{};
10857 return get_number(input_format, len) && get_string(input_format, len, result);
10863 return get_number(input_format, len) && get_string(input_format, len, result);
10868 std::int16_t len{};
10869 return get_number(input_format, len) && get_string(input_format, len, result);
10874 std::int32_t len{};
10875 return get_number(input_format, len) && get_string(input_format, len, result);
10880 std::int64_t len{};
10881 return get_number(input_format, len) && get_string(input_format, len, result);
10886 if (input_format != input_format_t::bjdata)
10890 std::uint16_t len{};
10891 return get_number(input_format, len) && get_string(input_format, len, result);
10896 if (input_format != input_format_t::bjdata)
10900 std::uint32_t len{};
10901 return get_number(input_format, len) && get_string(input_format, len, result);
10906 if (input_format != input_format_t::bjdata)
10910 std::uint64_t len{};
10911 return get_number(input_format, len) && get_string(input_format, len, result);
10917 auto last_token = get_token_string();
10918 std::string message;
10920 if (input_format != input_format_t::bjdata)
10922 message =
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token;
10926 message =
"expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token;
10928 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"string"),
nullptr));
10937 std::pair<std::size_t, char_int_type> size_and_type;
10939 bool no_ndarray =
true;
10946 if (size_and_type.first != string_t::npos)
10948 if (size_and_type.second != 0)
10950 if (size_and_type.second !=
'N')
10952 for (std::size_t i = 0; i < size_and_type.first; ++i)
10958 dim.push_back(dimlen);
10964 for (std::size_t i = 0; i < size_and_type.first; ++i)
10970 dim.push_back(dimlen);
10976 while (current !=
']')
10982 dim.push_back(dimlen);
11004 prefix = get_ignore_noop();
11011 std::uint8_t number{};
11016 result =
static_cast<std::size_t
>(number);
11022 std::int8_t number{};
11029 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11030 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11032 result =
static_cast<std::size_t
>(number);
11038 std::int16_t number{};
11045 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11046 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11048 result =
static_cast<std::size_t
>(number);
11054 std::int32_t number{};
11061 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11062 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11064 result =
static_cast<std::size_t
>(number);
11070 std::int64_t number{};
11077 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11078 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11080 if (!value_in_range_of<std::size_t>(number))
11082 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
11083 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11085 result =
static_cast<std::size_t
>(number);
11091 if (input_format != input_format_t::bjdata)
11095 std::uint16_t number{};
11100 result =
static_cast<std::size_t
>(number);
11106 if (input_format != input_format_t::bjdata)
11110 std::uint32_t number{};
11115 result = conditional_static_cast<std::size_t>(number);
11121 if (input_format != input_format_t::bjdata)
11125 std::uint64_t number{};
11130 if (!value_in_range_of<std::size_t>(number))
11132 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
11133 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11135 result = detail::conditional_static_cast<std::size_t>(number);
11141 if (input_format != input_format_t::bjdata)
11147 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format,
"ndarray dimentional vector is not allowed",
"size"),
nullptr));
11149 std::vector<size_t> dim;
11154 if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1))
11156 result = dim.at(dim.size() - 1);
11179 if (result == 0 || result == string_t::npos)
11181 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format,
"excessive ndarray size caused overflow",
"size"),
nullptr));
11189 return sax->end_array();
11198 auto last_token = get_token_string();
11199 std::string message;
11201 if (input_format != input_format_t::bjdata)
11203 message =
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token;
11207 message =
"expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token;
11209 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"size"),
nullptr));
11225 result.first = string_t::npos;
11227 bool is_ndarray =
false;
11231 if (current ==
'$')
11233 std::vector<char_int_type> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
11235 result.second =
get();
11236 if (
JSON_HEDLEY_UNLIKELY( input_format == input_format_t::bjdata && std::find(bjdx.begin(), bjdx.end(), result.second) != bjdx.end() ))
11238 auto last_token = get_token_string();
11239 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11240 exception_message(input_format,
concat(
"marker 0x", last_token,
" is not a permitted optimized array type"),
"type"),
nullptr));
11255 auto last_token = get_token_string();
11256 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11257 exception_message(input_format,
concat(
"expected '#' after type information; last byte: 0x", last_token),
"size"),
nullptr));
11260 bool is_error = get_ubjson_size_value(result.first, is_ndarray);
11261 if (input_format == input_format_t::bjdata && is_ndarray)
11263 if (inside_ndarray)
11265 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
11266 exception_message(input_format,
"ndarray can not be recursive",
"size"),
nullptr));
11268 result.second |= (1 << 8);
11273 if (current ==
'#')
11275 bool is_error = get_ubjson_size_value(result.first, is_ndarray);
11276 if (input_format == input_format_t::bjdata && is_ndarray)
11278 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
11279 exception_message(input_format,
"ndarray requires both type and size",
"size"),
nullptr));
11295 case std::char_traits<char_type>::eof():
11296 return unexpect_eof(input_format,
"value");
11299 return sax->boolean(
true);
11301 return sax->boolean(
false);
11304 return sax->null();
11308 std::uint8_t number{};
11309 return get_number(input_format, number) && sax->number_unsigned(number);
11314 std::int8_t number{};
11315 return get_number(input_format, number) && sax->number_integer(number);
11320 std::int16_t number{};
11321 return get_number(input_format, number) && sax->number_integer(number);
11326 std::int32_t number{};
11327 return get_number(input_format, number) && sax->number_integer(number);
11332 std::int64_t number{};
11333 return get_number(input_format, number) && sax->number_integer(number);
11338 if (input_format != input_format_t::bjdata)
11342 std::uint16_t number{};
11343 return get_number(input_format, number) && sax->number_unsigned(number);
11348 if (input_format != input_format_t::bjdata)
11352 std::uint32_t number{};
11353 return get_number(input_format, number) && sax->number_unsigned(number);
11358 if (input_format != input_format_t::bjdata)
11362 std::uint64_t number{};
11363 return get_number(input_format, number) && sax->number_unsigned(number);
11368 if (input_format != input_format_t::bjdata)
11372 const auto byte1_raw =
get();
11377 const auto byte2_raw =
get();
11383 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
11384 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
11394 const auto half =
static_cast<unsigned int>((byte2 << 8u) + byte1);
11395 const double val = [&half]
11397 const int exp = (half >> 10u) & 0x1Fu;
11398 const unsigned int mant = half & 0x3FFu;
11404 return std::ldexp(mant, -24);
11407 ? std::numeric_limits<double>::infinity()
11408 : std::numeric_limits<double>::quiet_NaN();
11410 return std::ldexp(mant + 1024, exp - 25);
11413 return sax->number_float((half & 0x8000u) != 0
11421 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
11427 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
11432 return get_ubjson_high_precision_number();
11444 auto last_token = get_token_string();
11445 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
11446 exception_message(input_format,
concat(
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token),
"char"),
nullptr));
11448 string_t s(1,
static_cast<typename string_t::value_type
>(current));
11449 return sax->string(s);
11455 return get_ubjson_string(s) && sax->string(s);
11459 return get_ubjson_array();
11462 return get_ubjson_object();
11467 auto last_token = get_token_string();
11468 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format,
"invalid byte: 0x" + last_token,
"value"),
nullptr));
11476 std::pair<std::size_t, char_int_type> size_and_type;
11485 if (input_format == input_format_t::bjdata && size_and_type.first != string_t::npos && (size_and_type.second & (1 << 8)) != 0)
11487 std::map<char_int_type, string_t> bjdtype = {{
'U',
"uint8"}, {
'i',
"int8"}, {
'u',
"uint16"}, {
'I',
"int16"},
11488 {
'm',
"uint32"}, {
'l',
"int32"}, {
'M',
"uint64"}, {
'L',
"int64"}, {
'd',
"single"}, {
'D',
"double"}, {
'C',
"char"}
11491 size_and_type.second &= ~(
static_cast<char_int_type>(1) << 8);
11496 auto last_token = get_token_string();
11497 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11498 exception_message(input_format,
"invalid byte: 0x" + last_token,
"type"),
nullptr));
11506 if (size_and_type.second ==
'C')
11508 size_and_type.second =
'U';
11511 key =
"_ArrayData_";
11517 for (std::size_t i = 0; i < size_and_type.first; ++i)
11525 return (sax->end_array() && sax->end_object());
11528 if (size_and_type.first != string_t::npos)
11535 if (size_and_type.second != 0)
11537 if (size_and_type.second !=
'N')
11539 for (std::size_t i = 0; i < size_and_type.first; ++i)
11550 for (std::size_t i = 0; i < size_and_type.first; ++i)
11566 while (current !=
']')
11576 return sax->end_array();
11584 std::pair<std::size_t, char_int_type> size_and_type;
11591 if (input_format == input_format_t::bjdata && size_and_type.first != string_t::npos && (size_and_type.second & (1 << 8)) != 0)
11593 auto last_token = get_token_string();
11594 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11595 exception_message(input_format,
"BJData object does not support ND-array size in optimized format",
"object"),
nullptr));
11599 if (size_and_type.first != string_t::npos)
11606 if (size_and_type.second != 0)
11608 for (std::size_t i = 0; i < size_and_type.first; ++i)
11623 for (std::size_t i = 0; i < size_and_type.first; ++i)
11644 while (current !=
'}')
11659 return sax->end_object();
11668 std::size_t size{};
11669 bool no_ndarray =
true;
11670 auto res = get_ubjson_size_value(size, no_ndarray);
11677 std::vector<char> number_vector;
11678 for (std::size_t i = 0; i < size; ++i)
11685 number_vector.push_back(
static_cast<char>(current));
11691 const auto result_number = number_lexer.scan();
11692 const auto number_string = number_lexer.get_token_string();
11693 const auto result_remainder = number_lexer.scan();
11699 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
11700 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11703 switch (result_number)
11705 case token_type::value_integer:
11706 return sax->number_integer(number_lexer.get_number_integer());
11707 case token_type::value_unsigned:
11708 return sax->number_unsigned(number_lexer.get_number_unsigned());
11709 case token_type::value_float:
11710 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
11711 case token_type::uninitialized:
11712 case token_type::literal_true:
11713 case token_type::literal_false:
11714 case token_type::literal_null:
11715 case token_type::value_string:
11716 case token_type::begin_array:
11717 case token_type::begin_object:
11718 case token_type::end_array:
11719 case token_type::end_object:
11720 case token_type::name_separator:
11721 case token_type::value_separator:
11722 case token_type::parse_error:
11723 case token_type::end_of_input:
11724 case token_type::literal_or_value:
11726 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
11727 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11747 return current = ia.get_character();
11759 while (current ==
'N');
11779 template<
typename NumberType,
bool InputIsLittleEndian = false>
11783 std::array<std::uint8_t,
sizeof(NumberType)> vec{};
11784 for (std::size_t i = 0; i <
sizeof(NumberType); ++i)
11793 if (is_little_endian != (InputIsLittleEndian || format == input_format_t::bjdata))
11795 vec[
sizeof(NumberType) - i - 1] =
static_cast<std::uint8_t
>(current);
11799 vec[i] =
static_cast<std::uint8_t
>(current);
11804 std::memcpy(&result, vec.data(),
sizeof(NumberType));
11822 template<
typename NumberType>
11824 const NumberType len,
11827 bool success =
true;
11828 for (NumberType i = 0; i < len; i++)
11836 result.push_back(
static_cast<typename string_t::value_type
>(current));
11855 template<
typename NumberType>
11857 const NumberType len,
11860 bool success =
true;
11861 for (NumberType i = 0; i < len; i++)
11869 result.push_back(
static_cast<std::uint8_t
>(current));
11884 return sax->parse_error(chars_read,
"<end of file>",
11885 parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
11895 std::array<char, 3> cr{{}};
11896 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
11897 return std::string{cr.data()};
11907 const std::string&
detail,
11908 const std::string& context)
const
11910 std::string error_msg =
"syntax error while parsing ";
11914 case input_format_t::cbor:
11915 error_msg +=
"CBOR";
11918 case input_format_t::msgpack:
11919 error_msg +=
"MessagePack";
11922 case input_format_t::ubjson:
11923 error_msg +=
"UBJSON";
11926 case input_format_t::bson:
11927 error_msg +=
"BSON";
11930 case input_format_t::bjdata:
11931 error_msg +=
"BJData";
11950 std::size_t chars_read = 0;
11982#include <functional>
12027template<
typename BasicJsonType>
12029 std::function<bool(
int ,
parse_event_t , BasicJsonType& )>;
12036template<
typename BasicJsonType,
typename InputAdapterType>
12050 const bool allow_exceptions_ =
true,
12051 const bool skip_comments =
false)
12053 , m_lexer(
std::move(adapter), skip_comments)
12054 , allow_exceptions(allow_exceptions_)
12070 void parse(
const bool strict, BasicJsonType& result)
12075 sax_parse_internal(&sdp);
12078 if (
strict && (get_token() != token_type::end_of_input))
12081 m_lexer.get_token_string(),
12082 parse_error::create(101, m_lexer.get_position(),
12083 exception_message(token_type::end_of_input,
"value"),
nullptr));
12089 result = value_t::discarded;
12095 if (result.is_discarded())
12103 sax_parse_internal(&sdp);
12106 if (
strict && (get_token() != token_type::end_of_input))
12109 m_lexer.get_token_string(),
12110 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
12116 result = value_t::discarded;
12121 result.assert_invariant();
12133 return sax_parse(&sax_acceptor,
strict);
12136 template<
typename SAX>
12138 bool sax_parse(SAX* sax, const
bool strict = true)
12141 const bool result = sax_parse_internal(sax);
12144 if (result &&
strict && (get_token() != token_type::end_of_input))
12146 return sax->parse_error(m_lexer.get_position(),
12147 m_lexer.get_token_string(),
12148 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
12155 template<
typename SAX>
12157 bool sax_parse_internal(SAX* sax)
12161 std::vector<bool> states;
12163 bool skip_to_state_evaluation =
false;
12167 if (!skip_to_state_evaluation)
12170 switch (last_token)
12172 case token_type::begin_object:
12180 if (get_token() == token_type::end_object)
12192 return sax->parse_error(m_lexer.get_position(),
12193 m_lexer.get_token_string(),
12194 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
12204 return sax->parse_error(m_lexer.get_position(),
12205 m_lexer.get_token_string(),
12206 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
12210 states.push_back(
false);
12217 case token_type::begin_array:
12225 if (get_token() == token_type::end_array)
12235 states.push_back(
true);
12241 case token_type::value_float:
12243 const auto res = m_lexer.get_number_float();
12247 return sax->parse_error(m_lexer.get_position(),
12248 m_lexer.get_token_string(),
12249 out_of_range::create(406,
concat(
"number overflow parsing '", m_lexer.get_token_string(),
'\''),
nullptr));
12260 case token_type::literal_false:
12269 case token_type::literal_null:
12278 case token_type::literal_true:
12287 case token_type::value_integer:
12296 case token_type::value_string:
12305 case token_type::value_unsigned:
12314 case token_type::parse_error:
12317 return sax->parse_error(m_lexer.get_position(),
12318 m_lexer.get_token_string(),
12319 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized,
"value"),
nullptr));
12322 case token_type::uninitialized:
12323 case token_type::end_array:
12324 case token_type::end_object:
12325 case token_type::name_separator:
12326 case token_type::value_separator:
12327 case token_type::end_of_input:
12328 case token_type::literal_or_value:
12331 return sax->parse_error(m_lexer.get_position(),
12332 m_lexer.get_token_string(),
12333 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
12339 skip_to_state_evaluation =
false;
12343 if (states.empty())
12352 if (get_token() == token_type::value_separator)
12373 skip_to_state_evaluation =
true;
12377 return sax->parse_error(m_lexer.get_position(),
12378 m_lexer.get_token_string(),
12379 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array,
"array"),
nullptr));
12385 if (get_token() == token_type::value_separator)
12390 return sax->parse_error(m_lexer.get_position(),
12391 m_lexer.get_token_string(),
12392 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
12403 return sax->parse_error(m_lexer.get_position(),
12404 m_lexer.get_token_string(),
12405 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
12427 skip_to_state_evaluation =
true;
12431 return sax->parse_error(m_lexer.get_position(),
12432 m_lexer.get_token_string(),
12433 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object,
"object"),
nullptr));
12440 return last_token = m_lexer.scan();
12445 std::string error_msg =
"syntax error ";
12447 if (!context.empty())
12449 error_msg +=
concat(
"while parsing ", context,
' ');
12454 if (last_token == token_type::parse_error)
12456 error_msg +=
concat(m_lexer.get_error_message(),
"; last read: '",
12457 m_lexer.get_token_string(),
'\'');
12461 error_msg +=
concat(
"unexpected ", lexer_t::token_type_name(last_token));
12464 if (expected != token_type::uninitialized)
12466 error_msg +=
concat(
"; expected ", lexer_t::token_type_name(expected));
12480 const bool allow_exceptions =
true;
12549 m_it = begin_value;
12561 return m_it == begin_value;
12567 return m_it == end_value;
12572 return lhs.m_it == rhs.m_it;
12577 return lhs.m_it < rhs.m_it;
12582 auto result = *
this;
12589 return lhs.m_it - rhs.m_it;
12600 auto result = *
this;
12613 auto result = *
this;
12648 typename BasicJsonType::object_t::iterator object_iterator {};
12650 typename BasicJsonType::array_t::iterator array_iterator {};
12670#include <type_traits>
12692template<
typename IteratorType>
class iteration_proxy;
12693template<
typename IteratorType>
class iteration_proxy_value;
12711template<
typename BasicJsonType>
12726 "iter_impl only accepts (const) basic_json");
12728 static_assert(std::is_base_of<std::bidirectional_iterator_tag, std::bidirectional_iterator_tag>::value
12729 && std::is_base_of<std::bidirectional_iterator_tag, typename std::iterator_traits<typename array_t::iterator>::iterator_category>::value,
12730 "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement.");
12745 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
12746 typename BasicJsonType::const_pointer,
12747 typename BasicJsonType::pointer>::type;
12750 typename std::conditional<std::is_const<BasicJsonType>::value,
12751 typename BasicJsonType::const_reference,
12752 typename BasicJsonType::reference>::type;
12769 switch (m_object->m_type)
12771 case value_t::object:
12773 m_it.object_iterator =
typename object_t::iterator();
12777 case value_t::array:
12779 m_it.array_iterator =
typename array_t::iterator();
12783 case value_t::null:
12784 case value_t::string:
12785 case value_t::boolean:
12786 case value_t::number_integer:
12787 case value_t::number_unsigned:
12788 case value_t::number_float:
12789 case value_t::binary:
12790 case value_t::discarded:
12816 : m_object(other.m_object), m_it(other.m_it)
12827 if (&other !=
this)
12829 m_object = other.m_object;
12841 : m_object(other.m_object), m_it(other.m_it)
12852 m_object = other.m_object;
12862 void set_begin() noexcept
12866 switch (m_object->m_type)
12868 case value_t::object:
12870 m_it.object_iterator = m_object->m_value.object->begin();
12874 case value_t::array:
12876 m_it.array_iterator = m_object->m_value.array->begin();
12880 case value_t::null:
12883 m_it.primitive_iterator.set_end();
12887 case value_t::string:
12888 case value_t::boolean:
12889 case value_t::number_integer:
12890 case value_t::number_unsigned:
12891 case value_t::number_float:
12892 case value_t::binary:
12893 case value_t::discarded:
12896 m_it.primitive_iterator.set_begin();
12910 switch (m_object->m_type)
12912 case value_t::object:
12914 m_it.object_iterator = m_object->m_value.object->end();
12918 case value_t::array:
12920 m_it.array_iterator = m_object->m_value.array->end();
12924 case value_t::null:
12925 case value_t::string:
12926 case value_t::boolean:
12927 case value_t::number_integer:
12928 case value_t::number_unsigned:
12929 case value_t::number_float:
12930 case value_t::binary:
12931 case value_t::discarded:
12934 m_it.primitive_iterator.set_end();
12949 switch (m_object->m_type)
12951 case value_t::object:
12953 JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end());
12954 return m_it.object_iterator->second;
12957 case value_t::array:
12959 JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end());
12960 return *m_it.array_iterator;
12963 case value_t::null:
12964 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
12966 case value_t::string:
12967 case value_t::boolean:
12968 case value_t::number_integer:
12969 case value_t::number_unsigned:
12970 case value_t::number_float:
12971 case value_t::binary:
12972 case value_t::discarded:
12980 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
12993 switch (m_object->m_type)
12995 case value_t::object:
12997 JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end());
12998 return &(m_it.object_iterator->second);
13001 case value_t::array:
13003 JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end());
13004 return &*m_it.array_iterator;
13007 case value_t::null:
13008 case value_t::string:
13009 case value_t::boolean:
13010 case value_t::number_integer:
13011 case value_t::number_unsigned:
13012 case value_t::number_float:
13013 case value_t::binary:
13014 case value_t::discarded:
13022 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13033 auto result = *
this;
13046 switch (m_object->m_type)
13048 case value_t::object:
13050 std::advance(m_it.object_iterator, 1);
13054 case value_t::array:
13056 std::advance(m_it.array_iterator, 1);
13060 case value_t::null:
13061 case value_t::string:
13062 case value_t::boolean:
13063 case value_t::number_integer:
13064 case value_t::number_unsigned:
13065 case value_t::number_float:
13066 case value_t::binary:
13067 case value_t::discarded:
13070 ++m_it.primitive_iterator;
13084 auto result = *
this;
13097 switch (m_object->m_type)
13099 case value_t::object:
13101 std::advance(m_it.object_iterator, -1);
13105 case value_t::array:
13107 std::advance(m_it.array_iterator, -1);
13111 case value_t::null:
13112 case value_t::string:
13113 case value_t::boolean:
13114 case value_t::number_integer:
13115 case value_t::number_unsigned:
13116 case value_t::number_float:
13117 case value_t::binary:
13118 case value_t::discarded:
13121 --m_it.primitive_iterator;
13133 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
13139 JSON_THROW(invalid_iterator::create(212,
"cannot compare iterators of different containers", m_object));
13144 switch (m_object->m_type)
13146 case value_t::object:
13147 return (m_it.object_iterator == other.m_it.object_iterator);
13149 case value_t::array:
13150 return (m_it.array_iterator == other.m_it.array_iterator);
13152 case value_t::null:
13153 case value_t::string:
13154 case value_t::boolean:
13155 case value_t::number_integer:
13156 case value_t::number_unsigned:
13157 case value_t::number_float:
13158 case value_t::binary:
13159 case value_t::discarded:
13161 return (m_it.primitive_iterator == other.m_it.primitive_iterator);
13169 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
13184 JSON_THROW(invalid_iterator::create(212,
"cannot compare iterators of different containers", m_object));
13189 switch (m_object->m_type)
13191 case value_t::object:
13192 JSON_THROW(invalid_iterator::create(213,
"cannot compare order of object iterators", m_object));
13194 case value_t::array:
13197 case value_t::null:
13198 case value_t::string:
13199 case value_t::boolean:
13200 case value_t::number_integer:
13201 case value_t::number_unsigned:
13202 case value_t::number_float:
13203 case value_t::binary:
13204 case value_t::discarded:
13216 return !other.operator < (*this);
13225 return !operator<=(other);
13245 switch (m_object->m_type)
13247 case value_t::object:
13248 JSON_THROW(invalid_iterator::create(209,
"cannot use offsets with object iterators", m_object));
13250 case value_t::array:
13252 std::advance(m_it.array_iterator, i);
13256 case value_t::null:
13257 case value_t::string:
13258 case value_t::boolean:
13259 case value_t::number_integer:
13260 case value_t::number_unsigned:
13261 case value_t::number_float:
13262 case value_t::binary:
13263 case value_t::discarded:
13266 m_it.primitive_iterator += i;
13280 return operator+=(-i);
13289 auto result = *
this;
13311 auto result = *
this;
13324 switch (m_object->m_type)
13326 case value_t::object:
13327 JSON_THROW(invalid_iterator::create(209,
"cannot use offsets with object iterators", m_object));
13329 case value_t::array:
13332 case value_t::null:
13333 case value_t::string:
13334 case value_t::boolean:
13335 case value_t::number_integer:
13336 case value_t::number_unsigned:
13337 case value_t::number_float:
13338 case value_t::binary:
13339 case value_t::discarded:
13353 switch (m_object->m_type)
13355 case value_t::object:
13356 JSON_THROW(invalid_iterator::create(208,
"cannot use operator[] for object iterators", m_object));
13358 case value_t::array:
13359 return *std::next(m_it.array_iterator, n);
13361 case value_t::null:
13362 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13364 case value_t::string:
13365 case value_t::boolean:
13366 case value_t::number_integer:
13367 case value_t::number_unsigned:
13368 case value_t::number_float:
13369 case value_t::binary:
13370 case value_t::discarded:
13378 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13387 const typename object_t::key_type&
key()
const
13393 return m_it.object_iterator->first;
13396 JSON_THROW(invalid_iterator::create(207,
"cannot use key() for non-object iterators", m_object));
13405 return operator*();
13464template<
typename Base>
13532 return *(this->operator+(n));
13538 auto it = --this->base();
13545 auto it = --this->base();
13546 return it.operator * ();
13566#include <algorithm>
13594template<
typename RefStringType>
13604 template<
typename T>
13623 : reference_tokens(split(s))
13630 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
13634 return detail::concat(a,
'/', detail::escape(b));
13660 reference_tokens.insert(reference_tokens.end(),
13670 push_back(std::move(token));
13726 reference_tokens.pop_back();
13738 return reference_tokens.back();
13745 reference_tokens.push_back(token);
13752 reference_tokens.push_back(std::move(token));
13759 return reference_tokens.empty();
13773 template<
typename BasicJsonType>
13776 using size_type =
typename BasicJsonType::size_type;
13790 const char* p = s.c_str();
13791 char* p_end =
nullptr;
13793 unsigned long long res = std::strtoull(p, &p_end, 10);
13803 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
13808 return static_cast<size_type
>(res);
13833 template<
typename BasicJsonType>
13840 for (
const auto& reference_token : reference_tokens)
13842 switch (result->type())
13846 if (reference_token ==
"0")
13849 result = &result->operator[](0);
13854 result = &result->operator[](reference_token);
13862 result = &result->operator[](reference_token);
13869 result = &result->operator[](array_index<BasicJsonType>(reference_token));
13913 template<
typename BasicJsonType>
13916 for (
const auto& reference_token : reference_tokens)
13919 if (ptr->is_null())
13923 std::all_of(reference_token.begin(), reference_token.end(),
13924 [](
const unsigned char x)
13926 return std::isdigit(x);
13930 *ptr = (nums || reference_token ==
"-")
13935 switch (ptr->type())
13940 ptr = &ptr->operator[](reference_token);
13946 if (reference_token ==
"-")
13949 ptr = &ptr->operator[](ptr->m_value.array->size());
13954 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
13981 template<
typename BasicJsonType>
13984 for (
const auto& reference_token : reference_tokens)
13986 switch (ptr->type())
13991 ptr = &ptr->at(reference_token);
14001 "array index '-' (",
std::to_string(ptr->m_value.array->size()),
14002 ") is out of range"), ptr));
14006 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
14039 template<
typename BasicJsonType>
14042 for (
const auto& reference_token : reference_tokens)
14044 switch (ptr->type())
14049 ptr = &ptr->operator[](reference_token);
14062 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
14088 template<
typename BasicJsonType>
14091 for (
const auto& reference_token : reference_tokens)
14093 switch (ptr->type())
14098 ptr = &ptr->at(reference_token);
14108 "array index '-' (",
std::to_string(ptr->m_value.array->size()),
14109 ") is out of range"), ptr));
14113 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
14137 template<
typename BasicJsonType>
14140 for (
const auto& reference_token : reference_tokens)
14142 switch (ptr->type())
14146 if (!ptr->contains(reference_token))
14152 ptr = &ptr->operator[](reference_token);
14163 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
14175 for (std::size_t i = 1; i < reference_token.size(); i++)
14185 const auto idx = array_index<BasicJsonType>(reference_token);
14186 if (idx >= ptr->size())
14192 ptr = &ptr->operator[](idx);
14228 std::vector<string_t> result;
14231 if (reference_string.empty())
14247 std::size_t slash = reference_string.find_first_of(
'/', 1),
14254 start = (slash == string_t::npos) ? 0 : slash + 1,
14256 slash = reference_string.find_first_of(
'/', start))
14260 auto reference_token = reference_string.substr(start, slash - start);
14263 for (std::size_t pos = reference_token.find_first_of(
'~');
14264 pos != string_t::npos;
14265 pos = reference_token.find_first_of(
'~', pos + 1))
14271 (reference_token[pos + 1] !=
'0' &&
14272 reference_token[pos + 1] !=
'1')))
14280 result.push_back(reference_token);
14294 template<
typename BasicJsonType>
14296 const BasicJsonType& value,
14297 BasicJsonType& result)
14299 switch (value.type())
14303 if (value.m_value.array->empty())
14306 result[reference_string] =
nullptr;
14311 for (std::size_t i = 0; i < value.m_value.array->size(); ++i)
14314 value.m_value.array->operator[](i), result);
14322 if (value.m_value.object->empty())
14325 result[reference_string] =
nullptr;
14330 for (
const auto& element : *value.m_value.object)
14349 result[reference_string] = value;
14365 template<
typename BasicJsonType>
14366 static BasicJsonType
14374 BasicJsonType result;
14377 for (
const auto& element : *value.m_value.object)
14420 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14436 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14446template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14450 return lhs.reference_tokens == rhs.reference_tokens;
14453template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14457 return !(lhs == rhs);
14473#include <initializer_list>
14485template<
typename BasicJsonType>
14496 : value_ref(&
value)
14500 : owned_value(init)
14505 enable_if_t<std::is_constructible<value_type, Args...>::value,
int> = 0 >
14507 : owned_value(
std::forward<Args>(args)...)
14519 if (value_ref ==
nullptr)
14521 return std::move(owned_value);
14528 return value_ref ? *value_ref : owned_value;
14565#include <algorithm>
14591#include <algorithm>
14625template<typename CharType>
14629template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
14643 void write_characters(const CharType* s,
std::
size_t length)
override
14645 v.insert(v.end(), s, s + length);
14649 std::vector<CharType, AllocatorType>&
v;
14654template<
typename CharType>
14668 void write_characters(const CharType* s,
std::
size_t length)
override
14670 stream.write(s,
static_cast<std::streamsize
>(length));
14679template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
14693 void write_characters(const CharType* s,
std::
size_t length)
override
14695 str.append(s, length);
14702template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
14706 template<
typename AllocatorType = std::allocator<CharType>>
14744template<
typename BasicJsonType,
typename CharType>
14770 case value_t::object:
14772 write_bson_object(*j.m_value.object);
14776 case value_t::null:
14777 case value_t::array:
14778 case value_t::string:
14779 case value_t::boolean:
14780 case value_t::number_integer:
14781 case value_t::number_unsigned:
14782 case value_t::number_float:
14783 case value_t::binary:
14784 case value_t::discarded:
14787 JSON_THROW(type_error::create(317,
concat(
"to serialize to BSON, top-level type must be object, but is ", j.type_name()), &j));
14799 case value_t::null:
14801 oa->write_character(to_char_type(0xF6));
14805 case value_t::boolean:
14807 oa->write_character(j.m_value.boolean
14808 ? to_char_type(0xF5)
14809 : to_char_type(0xF4));
14813 case value_t::number_integer:
14815 if (j.m_value.number_integer >= 0)
14820 if (j.m_value.number_integer <= 0x17)
14822 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14824 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
14826 oa->write_character(to_char_type(0x18));
14827 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14829 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
14831 oa->write_character(to_char_type(0x19));
14832 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
14834 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
14836 oa->write_character(to_char_type(0x1A));
14837 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
14841 oa->write_character(to_char_type(0x1B));
14842 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
14849 const auto positive_number = -1 - j.m_value.number_integer;
14850 if (j.m_value.number_integer >= -24)
14852 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
14854 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
14856 oa->write_character(to_char_type(0x38));
14857 write_number(
static_cast<std::uint8_t
>(positive_number));
14859 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
14861 oa->write_character(to_char_type(0x39));
14862 write_number(
static_cast<std::uint16_t
>(positive_number));
14864 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
14866 oa->write_character(to_char_type(0x3A));
14867 write_number(
static_cast<std::uint32_t
>(positive_number));
14871 oa->write_character(to_char_type(0x3B));
14872 write_number(
static_cast<std::uint64_t
>(positive_number));
14878 case value_t::number_unsigned:
14880 if (j.m_value.number_unsigned <= 0x17)
14882 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
14884 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
14886 oa->write_character(to_char_type(0x18));
14887 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
14889 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
14891 oa->write_character(to_char_type(0x19));
14892 write_number(
static_cast<std::uint16_t
>(j.m_value.number_unsigned));
14894 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
14896 oa->write_character(to_char_type(0x1A));
14897 write_number(
static_cast<std::uint32_t
>(j.m_value.number_unsigned));
14901 oa->write_character(to_char_type(0x1B));
14902 write_number(
static_cast<std::uint64_t
>(j.m_value.number_unsigned));
14907 case value_t::number_float:
14909 if (std::isnan(j.m_value.number_float))
14912 oa->write_character(to_char_type(0xF9));
14913 oa->write_character(to_char_type(0x7E));
14914 oa->write_character(to_char_type(0x00));
14916 else if (std::isinf(j.m_value.number_float))
14919 oa->write_character(to_char_type(0xf9));
14920 oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
14921 oa->write_character(to_char_type(0x00));
14930 case value_t::string:
14933 const auto N = j.m_value.string->size();
14936 write_number(
static_cast<std::uint8_t
>(0x60 + N));
14938 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14940 oa->write_character(to_char_type(0x78));
14941 write_number(
static_cast<std::uint8_t
>(N));
14943 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14945 oa->write_character(to_char_type(0x79));
14946 write_number(
static_cast<std::uint16_t
>(N));
14948 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14950 oa->write_character(to_char_type(0x7A));
14951 write_number(
static_cast<std::uint32_t
>(N));
14954 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
14956 oa->write_character(to_char_type(0x7B));
14957 write_number(
static_cast<std::uint64_t
>(N));
14962 oa->write_characters(
14963 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
14964 j.m_value.string->size());
14968 case value_t::array:
14971 const auto N = j.m_value.array->size();
14974 write_number(
static_cast<std::uint8_t
>(0x80 + N));
14976 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14978 oa->write_character(to_char_type(0x98));
14979 write_number(
static_cast<std::uint8_t
>(N));
14981 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14983 oa->write_character(to_char_type(0x99));
14984 write_number(
static_cast<std::uint16_t
>(N));
14986 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14988 oa->write_character(to_char_type(0x9A));
14989 write_number(
static_cast<std::uint32_t
>(N));
14992 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
14994 oa->write_character(to_char_type(0x9B));
14995 write_number(
static_cast<std::uint64_t
>(N));
15000 for (
const auto& el : *j.m_value.array)
15007 case value_t::binary:
15009 if (j.m_value.binary->has_subtype())
15011 if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
15013 write_number(
static_cast<std::uint8_t
>(0xd8));
15014 write_number(
static_cast<std::uint8_t
>(j.m_value.binary->subtype()));
15016 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
15018 write_number(
static_cast<std::uint8_t
>(0xd9));
15019 write_number(
static_cast<std::uint16_t
>(j.m_value.binary->subtype()));
15021 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
15023 write_number(
static_cast<std::uint8_t
>(0xda));
15024 write_number(
static_cast<std::uint32_t
>(j.m_value.binary->subtype()));
15026 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
15028 write_number(
static_cast<std::uint8_t
>(0xdb));
15029 write_number(
static_cast<std::uint64_t
>(j.m_value.binary->subtype()));
15034 const auto N = j.m_value.binary->size();
15037 write_number(
static_cast<std::uint8_t
>(0x40 + N));
15039 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15041 oa->write_character(to_char_type(0x58));
15042 write_number(
static_cast<std::uint8_t
>(N));
15044 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15046 oa->write_character(to_char_type(0x59));
15047 write_number(
static_cast<std::uint16_t
>(N));
15049 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15051 oa->write_character(to_char_type(0x5A));
15052 write_number(
static_cast<std::uint32_t
>(N));
15055 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15057 oa->write_character(to_char_type(0x5B));
15058 write_number(
static_cast<std::uint64_t
>(N));
15063 oa->write_characters(
15064 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
15070 case value_t::object:
15073 const auto N = j.m_value.object->size();
15076 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
15078 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15080 oa->write_character(to_char_type(0xB8));
15081 write_number(
static_cast<std::uint8_t
>(N));
15083 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15085 oa->write_character(to_char_type(0xB9));
15086 write_number(
static_cast<std::uint16_t
>(N));
15088 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15090 oa->write_character(to_char_type(0xBA));
15091 write_number(
static_cast<std::uint32_t
>(N));
15094 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15096 oa->write_character(to_char_type(0xBB));
15097 write_number(
static_cast<std::uint64_t
>(N));
15102 for (
const auto& el : *j.m_value.object)
15104 write_cbor(el.first);
15105 write_cbor(el.second);
15110 case value_t::discarded:
15123 case value_t::null:
15125 oa->write_character(to_char_type(0xC0));
15129 case value_t::boolean:
15131 oa->write_character(j.m_value.boolean
15132 ? to_char_type(0xC3)
15133 : to_char_type(0xC2));
15137 case value_t::number_integer:
15139 if (j.m_value.number_integer >= 0)
15144 if (j.m_value.number_unsigned < 128)
15147 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
15149 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15152 oa->write_character(to_char_type(0xCC));
15153 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
15155 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15158 oa->write_character(to_char_type(0xCD));
15159 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
15161 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15164 oa->write_character(to_char_type(0xCE));
15165 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
15167 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15170 oa->write_character(to_char_type(0xCF));
15171 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
15176 if (j.m_value.number_integer >= -32)
15179 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
15181 else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
15182 j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
15185 oa->write_character(to_char_type(0xD0));
15186 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
15188 else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
15189 j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
15192 oa->write_character(to_char_type(0xD1));
15193 write_number(
static_cast<std::int16_t
>(j.m_value.number_integer));
15195 else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
15196 j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
15199 oa->write_character(to_char_type(0xD2));
15200 write_number(
static_cast<std::int32_t
>(j.m_value.number_integer));
15202 else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
15203 j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
15206 oa->write_character(to_char_type(0xD3));
15207 write_number(
static_cast<std::int64_t
>(j.m_value.number_integer));
15213 case value_t::number_unsigned:
15215 if (j.m_value.number_unsigned < 128)
15218 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
15220 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15223 oa->write_character(to_char_type(0xCC));
15224 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
15226 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15229 oa->write_character(to_char_type(0xCD));
15230 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
15232 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15235 oa->write_character(to_char_type(0xCE));
15236 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
15238 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15241 oa->write_character(to_char_type(0xCF));
15242 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
15247 case value_t::number_float:
15253 case value_t::string:
15256 const auto N = j.m_value.string->size();
15260 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
15262 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15265 oa->write_character(to_char_type(0xD9));
15266 write_number(
static_cast<std::uint8_t
>(N));
15268 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15271 oa->write_character(to_char_type(0xDA));
15272 write_number(
static_cast<std::uint16_t
>(N));
15274 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15277 oa->write_character(to_char_type(0xDB));
15278 write_number(
static_cast<std::uint32_t
>(N));
15282 oa->write_characters(
15283 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
15284 j.m_value.string->size());
15288 case value_t::array:
15291 const auto N = j.m_value.array->size();
15295 write_number(
static_cast<std::uint8_t
>(0x90 | N));
15297 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15300 oa->write_character(to_char_type(0xDC));
15301 write_number(
static_cast<std::uint16_t
>(N));
15303 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15306 oa->write_character(to_char_type(0xDD));
15307 write_number(
static_cast<std::uint32_t
>(N));
15311 for (
const auto& el : *j.m_value.array)
15318 case value_t::binary:
15322 const bool use_ext = j.m_value.binary->has_subtype();
15325 const auto N = j.m_value.binary->size();
15326 if (N <= (std::numeric_limits<std::uint8_t>::max)())
15328 std::uint8_t output_type{};
15335 output_type = 0xD4;
15338 output_type = 0xD5;
15341 output_type = 0xD6;
15344 output_type = 0xD7;
15347 output_type = 0xD8;
15350 output_type = 0xC7;
15358 output_type = 0xC4;
15362 oa->write_character(to_char_type(output_type));
15365 write_number(
static_cast<std::uint8_t
>(N));
15368 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15370 std::uint8_t output_type = use_ext
15374 oa->write_character(to_char_type(output_type));
15375 write_number(
static_cast<std::uint16_t
>(N));
15377 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15379 std::uint8_t output_type = use_ext
15383 oa->write_character(to_char_type(output_type));
15384 write_number(
static_cast<std::uint32_t
>(N));
15390 write_number(
static_cast<std::int8_t
>(j.m_value.binary->subtype()));
15394 oa->write_characters(
15395 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
15401 case value_t::object:
15404 const auto N = j.m_value.object->size();
15408 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
15410 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15413 oa->write_character(to_char_type(0xDE));
15414 write_number(
static_cast<std::uint16_t
>(N));
15416 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15419 oa->write_character(to_char_type(0xDF));
15420 write_number(
static_cast<std::uint32_t
>(N));
15424 for (
const auto& el : *j.m_value.object)
15426 write_msgpack(el.first);
15427 write_msgpack(el.second);
15432 case value_t::discarded:
15446 const bool use_type,
const bool add_prefix =
true,
15447 const bool use_bjdata =
false)
15451 case value_t::null:
15455 oa->write_character(to_char_type(
'Z'));
15460 case value_t::boolean:
15464 oa->write_character(j.m_value.boolean
15465 ? to_char_type(
'T')
15466 : to_char_type(
'F'));
15471 case value_t::number_integer:
15473 write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix, use_bjdata);
15477 case value_t::number_unsigned:
15479 write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix, use_bjdata);
15483 case value_t::number_float:
15485 write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix, use_bjdata);
15489 case value_t::string:
15493 oa->write_character(to_char_type(
'S'));
15495 write_number_with_ubjson_prefix(j.m_value.string->size(),
true, use_bjdata);
15496 oa->write_characters(
15497 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
15498 j.m_value.string->size());
15502 case value_t::array:
15506 oa->write_character(to_char_type(
'['));
15509 bool prefix_required =
true;
15510 if (use_type && !j.m_value.array->empty())
15513 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
15514 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
15515 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
15517 return ubjson_prefix(v, use_bjdata) == first_prefix;
15520 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
15522 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
15524 prefix_required =
false;
15525 oa->write_character(to_char_type(
'$'));
15526 oa->write_character(first_prefix);
15532 oa->write_character(to_char_type(
'#'));
15533 write_number_with_ubjson_prefix(j.m_value.array->size(),
true, use_bjdata);
15536 for (
const auto& el : *j.m_value.array)
15538 write_ubjson(el, use_count, use_type, prefix_required, use_bjdata);
15543 oa->write_character(to_char_type(
']'));
15549 case value_t::binary:
15553 oa->write_character(to_char_type(
'['));
15556 if (use_type && !j.m_value.binary->empty())
15559 oa->write_character(to_char_type(
'$'));
15560 oa->write_character(
'U');
15565 oa->write_character(to_char_type(
'#'));
15566 write_number_with_ubjson_prefix(j.m_value.binary->size(),
true, use_bjdata);
15571 oa->write_characters(
15572 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
15573 j.m_value.binary->size());
15577 for (
size_t i = 0; i < j.m_value.binary->size(); ++i)
15579 oa->write_character(to_char_type(
'U'));
15580 oa->write_character(j.m_value.binary->data()[i]);
15586 oa->write_character(to_char_type(
']'));
15592 case value_t::object:
15594 if (use_bjdata && j.m_value.object->size() == 3 && j.m_value.object->find(
"_ArrayType_") != j.m_value.object->end() && j.m_value.object->find(
"_ArraySize_") != j.m_value.object->end() && j.m_value.object->find(
"_ArrayData_") != j.m_value.object->end())
15596 if (!write_bjdata_ndarray(*j.m_value.object, use_count, use_type))
15604 oa->write_character(to_char_type(
'{'));
15607 bool prefix_required =
true;
15608 if (use_type && !j.m_value.object->empty())
15611 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
15612 const bool same_prefix = std::all_of(j.begin(), j.end(),
15613 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
15615 return ubjson_prefix(v, use_bjdata) == first_prefix;
15618 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
15620 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
15622 prefix_required =
false;
15623 oa->write_character(to_char_type(
'$'));
15624 oa->write_character(first_prefix);
15630 oa->write_character(to_char_type(
'#'));
15631 write_number_with_ubjson_prefix(j.m_value.object->size(),
true, use_bjdata);
15634 for (
const auto& el : *j.m_value.object)
15636 write_number_with_ubjson_prefix(el.first.size(),
true, use_bjdata);
15637 oa->write_characters(
15638 reinterpret_cast<const CharType*
>(el.first.c_str()),
15640 write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata);
15645 oa->write_character(to_char_type(
'}'));
15651 case value_t::discarded:
15668 const auto it =
name.find(
static_cast<typename string_t::value_type
>(0));
15672 static_cast<void>(j);
15675 return 1ul +
name.size() + 1u;
15682 const std::uint8_t element_type)
15684 oa->write_character(to_char_type(element_type));
15685 oa->write_characters(
15686 reinterpret_cast<const CharType*
>(
name.c_str()),
15696 write_bson_entry_header(
name, 0x08);
15697 oa->write_character(
value ? to_char_type(0x01) : to_char_type(0x00));
15704 const double value)
15706 write_bson_entry_header(
name, 0x01);
15707 write_number<double>(
value,
true);
15715 return sizeof(std::int32_t) +
value.size() + 1ul;
15724 write_bson_entry_header(
name, 0x02);
15726 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size() + 1ul),
true);
15727 oa->write_characters(
15728 reinterpret_cast<const CharType*
>(
value.c_str()),
15737 write_bson_entry_header(
name, 0x0A);
15745 return (std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)()
15746 ?
sizeof(std::int32_t)
15747 :
sizeof(std::int64_t);
15754 const std::int64_t value)
15756 if ((std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)())
15758 write_bson_entry_header(
name, 0x10);
15759 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value),
true);
15763 write_bson_entry_header(
name, 0x12);
15764 write_number<std::int64_t>(
static_cast<std::int64_t
>(
value),
true);
15773 return (
value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15774 ?
sizeof(std::int32_t)
15775 :
sizeof(std::int64_t);
15782 const BasicJsonType& j)
15784 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15786 write_bson_entry_header(
name, 0x10 );
15787 write_number<std::int32_t>(
static_cast<std::int32_t
>(j.m_value.number_unsigned),
true);
15789 else if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
15791 write_bson_entry_header(
name, 0x12 );
15792 write_number<std::int64_t>(
static_cast<std::int64_t
>(j.m_value.number_unsigned),
true);
15796 JSON_THROW(out_of_range::create(407,
concat(
"integer number ",
std::to_string(j.m_value.number_unsigned),
" cannot be represented by BSON as it does not fit int64"), &j));
15804 const typename BasicJsonType::object_t& value)
15806 write_bson_entry_header(
name, 0x03);
15807 write_bson_object(
value);
15815 std::size_t array_index = 0ul;
15817 const std::size_t embedded_document_size = std::accumulate(std::begin(
value), std::end(
value),
static_cast<std::size_t
>(0), [&array_index](std::size_t result,
const typename BasicJsonType::array_t::value_type & el)
15819 return result + calc_bson_element_size(
std::to_string(array_index++), el);
15822 return sizeof(std::int32_t) + embedded_document_size + 1ul;
15830 return sizeof(std::int32_t) +
value.size() + 1ul;
15837 const typename BasicJsonType::array_t& value)
15839 write_bson_entry_header(
name, 0x04);
15840 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_array_size(
value)),
true);
15842 std::size_t array_index = 0ul;
15844 for (
const auto& el :
value)
15849 oa->write_character(to_char_type(0x00));
15858 write_bson_entry_header(
name, 0x05);
15860 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size()),
true);
15861 write_number(
value.has_subtype() ?
static_cast<std::uint8_t
>(
value.subtype()) :
static_cast<std::uint8_t
>(0x00));
15863 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
15871 const BasicJsonType& j)
15873 const auto header_size = calc_bson_entry_header_size(
name, j);
15876 case value_t::object:
15877 return header_size + calc_bson_object_size(*j.m_value.object);
15879 case value_t::array:
15880 return header_size + calc_bson_array_size(*j.m_value.array);
15882 case value_t::binary:
15883 return header_size + calc_bson_binary_size(*j.m_value.binary);
15885 case value_t::boolean:
15886 return header_size + 1ul;
15888 case value_t::number_float:
15889 return header_size + 8ul;
15891 case value_t::number_integer:
15892 return header_size + calc_bson_integer_size(j.m_value.number_integer);
15894 case value_t::number_unsigned:
15895 return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned);
15897 case value_t::string:
15898 return header_size + calc_bson_string_size(*j.m_value.string);
15900 case value_t::null:
15901 return header_size + 0ul;
15904 case value_t::discarded:
15919 const BasicJsonType& j)
15923 case value_t::object:
15924 return write_bson_object_entry(
name, *j.m_value.object);
15926 case value_t::array:
15927 return write_bson_array(
name, *j.m_value.array);
15929 case value_t::binary:
15930 return write_bson_binary(
name, *j.m_value.binary);
15932 case value_t::boolean:
15933 return write_bson_boolean(
name, j.m_value.boolean);
15935 case value_t::number_float:
15936 return write_bson_double(
name, j.m_value.number_float);
15938 case value_t::number_integer:
15939 return write_bson_integer(
name, j.m_value.number_integer);
15941 case value_t::number_unsigned:
15942 return write_bson_unsigned(
name, j);
15944 case value_t::string:
15945 return write_bson_string(
name, *j.m_value.string);
15947 case value_t::null:
15948 return write_bson_null(
name);
15951 case value_t::discarded:
15967 std::size_t document_size = std::accumulate(
value.begin(),
value.end(),
static_cast<std::size_t
>(0),
15968 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
15970 return result += calc_bson_element_size(el.first, el.second);
15973 return sizeof(std::int32_t) + document_size + 1ul;
15982 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_object_size(
value)),
true);
15984 for (
const auto& el :
value)
15986 write_bson_element(el.first, el.second);
15989 oa->write_character(to_char_type(0x00));
15998 return to_char_type(0xFA);
16003 return to_char_type(0xFB);
16012 return to_char_type(0xCA);
16017 return to_char_type(0xCB);
16025 template<
typename NumberType,
typename std::enable_if<
16026 std::is_floating_point<NumberType>::value,
int>::type = 0>
16028 const bool add_prefix,
16029 const bool use_bjdata)
16033 oa->write_character(get_ubjson_float_prefix(n));
16035 write_number(n, use_bjdata);
16039 template<
typename NumberType,
typename std::enable_if<
16040 std::is_unsigned<NumberType>::value,
int>::type = 0>
16042 const bool add_prefix,
16043 const bool use_bjdata)
16045 if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
16049 oa->write_character(to_char_type(
'i'));
16051 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
16053 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
16057 oa->write_character(to_char_type(
'U'));
16059 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
16061 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
16065 oa->write_character(to_char_type(
'I'));
16067 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
16069 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint16_t>::max)()))
16073 oa->write_character(to_char_type(
'u'));
16075 write_number(
static_cast<std::uint16_t
>(n), use_bjdata);
16077 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16081 oa->write_character(to_char_type(
'l'));
16083 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
16085 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint32_t>::max)()))
16089 oa->write_character(to_char_type(
'm'));
16091 write_number(
static_cast<std::uint32_t
>(n), use_bjdata);
16093 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16097 oa->write_character(to_char_type(
'L'));
16099 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
16101 else if (use_bjdata && n <= (std::numeric_limits<uint64_t>::max)())
16105 oa->write_character(to_char_type(
'M'));
16107 write_number(
static_cast<std::uint64_t
>(n), use_bjdata);
16113 oa->write_character(to_char_type(
'H'));
16116 const auto number = BasicJsonType(n).dump();
16117 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
16118 for (std::size_t i = 0; i < number.size(); ++i)
16120 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
16126 template <
typename NumberType,
typename std::enable_if <
16127 std::is_signed<NumberType>::value&&
16128 !std::is_floating_point<NumberType>::value,
int >::type = 0 >
16130 const bool add_prefix,
16131 const bool use_bjdata)
16133 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
16137 oa->write_character(to_char_type(
'i'));
16139 write_number(
static_cast<std::int8_t
>(n), use_bjdata);
16141 else if (
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::max)()))
16145 oa->write_character(to_char_type(
'U'));
16147 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
16149 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
16153 oa->write_character(to_char_type(
'I'));
16155 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
16157 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::max)())))
16161 oa->write_character(to_char_type(
'u'));
16163 write_number(
static_cast<uint16_t
>(n), use_bjdata);
16165 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
16169 oa->write_character(to_char_type(
'l'));
16171 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
16173 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::max)())))
16177 oa->write_character(to_char_type(
'm'));
16179 write_number(
static_cast<uint32_t
>(n), use_bjdata);
16181 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
16185 oa->write_character(to_char_type(
'L'));
16187 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
16194 oa->write_character(to_char_type(
'H'));
16197 const auto number = BasicJsonType(n).dump();
16198 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
16199 for (std::size_t i = 0; i < number.size(); ++i)
16201 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
16210 CharType
ubjson_prefix(
const BasicJsonType& j,
const bool use_bjdata)
const noexcept
16214 case value_t::null:
16217 case value_t::boolean:
16218 return j.m_value.boolean ?
'T' :
'F';
16220 case value_t::number_integer:
16222 if ((std::numeric_limits<std::int8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
16226 if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
16230 if ((std::numeric_limits<std::int16_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
16234 if (use_bjdata && ((std::numeric_limits<std::uint16_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)()))
16238 if ((std::numeric_limits<std::int32_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
16242 if (use_bjdata && ((std::numeric_limits<std::uint32_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)()))
16246 if ((std::numeric_limits<std::int64_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
16254 case value_t::number_unsigned:
16256 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
16260 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
16264 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
16268 if (use_bjdata && j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint16_t>::max)()))
16272 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16276 if (use_bjdata && j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint32_t>::max)()))
16280 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16284 if (use_bjdata && j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16292 case value_t::number_float:
16293 return get_ubjson_float_prefix(j.m_value.number_float);
16295 case value_t::string:
16298 case value_t::array:
16299 case value_t::binary:
16302 case value_t::object:
16305 case value_t::discarded:
16326 std::map<string_t, CharType> bjdtype = {{
"uint8",
'U'}, {
"int8",
'i'}, {
"uint16",
'u'}, {
"int16",
'I'},
16327 {
"uint32",
'm'}, {
"int32",
'l'}, {
"uint64",
'M'}, {
"int64",
'L'}, {
"single",
'd'}, {
"double",
'D'}, {
"char",
'C'}
16332 if (it == bjdtype.end())
16336 CharType dtype = it->second;
16338 key =
"_ArraySize_";
16339 std::size_t len = (
value.at(
key).empty() ? 0 : 1);
16340 for (
const auto& el :
value.at(
key))
16342 len *=
static_cast<std::size_t
>(el.m_value.number_unsigned);
16345 key =
"_ArrayData_";
16351 oa->write_character(
'[');
16352 oa->write_character(
'$');
16353 oa->write_character(dtype);
16354 oa->write_character(
'#');
16356 key =
"_ArraySize_";
16357 write_ubjson(
value.at(
key), use_count, use_type,
true,
true);
16359 key =
"_ArrayData_";
16360 if (dtype ==
'U' || dtype ==
'C')
16362 for (
const auto& el :
value.at(
key))
16364 write_number(
static_cast<std::uint8_t
>(el.m_value.number_unsigned),
true);
16367 else if (dtype ==
'i')
16369 for (
const auto& el :
value.at(
key))
16371 write_number(
static_cast<std::int8_t
>(el.m_value.number_integer),
true);
16374 else if (dtype ==
'u')
16376 for (
const auto& el :
value.at(
key))
16378 write_number(
static_cast<std::uint16_t
>(el.m_value.number_unsigned),
true);
16381 else if (dtype ==
'I')
16383 for (
const auto& el :
value.at(
key))
16385 write_number(
static_cast<std::int16_t
>(el.m_value.number_integer),
true);
16388 else if (dtype ==
'm')
16390 for (
const auto& el :
value.at(
key))
16392 write_number(
static_cast<std::uint32_t
>(el.m_value.number_unsigned),
true);
16395 else if (dtype ==
'l')
16397 for (
const auto& el :
value.at(
key))
16399 write_number(
static_cast<std::int32_t
>(el.m_value.number_integer),
true);
16402 else if (dtype ==
'M')
16404 for (
const auto& el :
value.at(
key))
16406 write_number(
static_cast<std::uint64_t
>(el.m_value.number_unsigned),
true);
16409 else if (dtype ==
'L')
16411 for (
const auto& el :
value.at(
key))
16413 write_number(
static_cast<std::int64_t
>(el.m_value.number_integer),
true);
16416 else if (dtype ==
'd')
16418 for (
const auto& el :
value.at(
key))
16420 write_number(
static_cast<float>(el.m_value.number_float),
true);
16423 else if (dtype ==
'D')
16425 for (
const auto& el :
value.at(
key))
16427 write_number(
static_cast<double>(el.m_value.number_float),
true);
16450 template<
typename NumberType>
16454 std::array<CharType,
sizeof(NumberType)> vec{};
16455 std::memcpy(vec.data(), &n,
sizeof(NumberType));
16458 if (is_little_endian != OutputIsLittleEndian)
16461 std::reverse(vec.begin(), vec.end());
16464 oa->write_characters(vec.data(),
sizeof(NumberType));
16470#pragma GCC diagnostic push
16471#pragma GCC diagnostic ignored "-Wfloat-equal"
16473 if (
static_cast<double>(n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
16474 static_cast<double>(n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
16475 static_cast<double>(
static_cast<float>(n)) ==
static_cast<double>(n))
16478 ? get_cbor_float_prefix(
static_cast<float>(n))
16479 : get_msgpack_float_prefix(
static_cast<float>(n)));
16480 write_number(
static_cast<float>(n));
16485 ? get_cbor_float_prefix(n)
16486 : get_msgpack_float_prefix(n));
16490#pragma GCC diagnostic pop
16499 template <
typename C = CharType,
16503 return *
reinterpret_cast<char*
>(&x);
16506 template <
typename C = CharType,
16510 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
16511 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
16513 std::memcpy(&result, &x,
sizeof(x));
16517 template<
typename C = CharType,
16524 template <
typename InputCharType,
typename C = CharType,
16526 std::is_signed<C>::value &&
16527 std::is_signed<char>::value &&
16528 std::is_same<char, typename std::remove_cv<InputCharType>::type>::value
16560#include <algorithm>
16570#include <type_traits>
16590#include <type_traits>
16621template<
typename Target,
typename Source>
16624 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
16627 std::memcpy(&target, &source,
sizeof(Source));
16633 static constexpr int kPrecision = 64;
16638 constexpr diyfp(std::uint64_t f_,
int e_) noexcept :
f(f_), e(e_) {}
16649 return {x.f - y.f, x.e};
16658 static_assert(kPrecision == 64,
"internal error");
16683 const std::uint64_t u_lo = x.
f & 0xFFFFFFFFu;
16684 const std::uint64_t u_hi = x.f >> 32u;
16685 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
16686 const std::uint64_t v_hi = y.f >> 32u;
16688 const std::uint64_t p0 = u_lo * v_lo;
16689 const std::uint64_t p1 = u_lo * v_hi;
16690 const std::uint64_t p2 = u_hi * v_lo;
16691 const std::uint64_t p3 = u_hi * v_hi;
16693 const std::uint64_t p0_hi = p0 >> 32u;
16694 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
16695 const std::uint64_t p1_hi = p1 >> 32u;
16696 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
16697 const std::uint64_t p2_hi = p2 >> 32u;
16699 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
16710 Q += std::uint64_t{1} << (64u - 32u - 1u);
16712 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
16714 return {h, x.e + y.e + 64};
16725 while ((x.f >> 63u) == 0)
16740 const int delta = x.
e - target_exponent;
16745 return {x.f << delta, target_exponent};
16762template<
typename FloatType>
16775 static_assert(std::numeric_limits<FloatType>::is_iec559,
16776 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
16778 constexpr int kPrecision = std::numeric_limits<FloatType>::digits;
16779 constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
16780 constexpr int kMinExp = 1 - kBias;
16781 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
16783 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
16785 const auto bits =
static_cast<std::uint64_t
>(reinterpret_bits<bits_type>(
value));
16786 const std::uint64_t E = bits >> (kPrecision - 1);
16787 const std::uint64_t F = bits & (kHiddenBit - 1);
16789 const bool is_denormal = E == 0;
16790 const diyfp v = is_denormal
16791 ?
diyfp(F, kMinExp)
16792 :
diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
16815 const bool lower_boundary_is_closer = F == 0 && E > 1;
16817 const diyfp m_minus = lower_boundary_is_closer
16818 ?
diyfp(4 * v.
f - 1, v.
e - 2)
16819 :
diyfp(2 * v.
f - 1, v.
e - 1);
16822 const diyfp w_plus = diyfp::normalize(m_plus);
16825 const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.
e);
16827 return {diyfp::normalize(v), w_minus, w_plus};
16954 constexpr int kCachedPowersMinDecExp = -300;
16955 constexpr int kCachedPowersDecStep = 8;
16957 static constexpr std::array<cached_power, 79> kCachedPowers =
16960 { 0xAB70FE17C79AC6CA, -1060, -300 },
16961 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
16962 { 0xBE5691EF416BD60C, -1007, -284 },
16963 { 0x8DD01FAD907FFC3C, -980, -276 },
16964 { 0xD3515C2831559A83, -954, -268 },
16965 { 0x9D71AC8FADA6C9B5, -927, -260 },
16966 { 0xEA9C227723EE8BCB, -901, -252 },
16967 { 0xAECC49914078536D, -874, -244 },
16968 { 0x823C12795DB6CE57, -847, -236 },
16969 { 0xC21094364DFB5637, -821, -228 },
16970 { 0x9096EA6F3848984F, -794, -220 },
16971 { 0xD77485CB25823AC7, -768, -212 },
16972 { 0xA086CFCD97BF97F4, -741, -204 },
16973 { 0xEF340A98172AACE5, -715, -196 },
16974 { 0xB23867FB2A35B28E, -688, -188 },
16975 { 0x84C8D4DFD2C63F3B, -661, -180 },
16976 { 0xC5DD44271AD3CDBA, -635, -172 },
16977 { 0x936B9FCEBB25C996, -608, -164 },
16978 { 0xDBAC6C247D62A584, -582, -156 },
16979 { 0xA3AB66580D5FDAF6, -555, -148 },
16980 { 0xF3E2F893DEC3F126, -529, -140 },
16981 { 0xB5B5ADA8AAFF80B8, -502, -132 },
16982 { 0x87625F056C7C4A8B, -475, -124 },
16983 { 0xC9BCFF6034C13053, -449, -116 },
16984 { 0x964E858C91BA2655, -422, -108 },
16985 { 0xDFF9772470297EBD, -396, -100 },
16986 { 0xA6DFBD9FB8E5B88F, -369, -92 },
16987 { 0xF8A95FCF88747D94, -343, -84 },
16988 { 0xB94470938FA89BCF, -316, -76 },
16989 { 0x8A08F0F8BF0F156B, -289, -68 },
16990 { 0xCDB02555653131B6, -263, -60 },
16991 { 0x993FE2C6D07B7FAC, -236, -52 },
16992 { 0xE45C10C42A2B3B06, -210, -44 },
16993 { 0xAA242499697392D3, -183, -36 },
16994 { 0xFD87B5F28300CA0E, -157, -28 },
16995 { 0xBCE5086492111AEB, -130, -20 },
16996 { 0x8CBCCC096F5088CC, -103, -12 },
16997 { 0xD1B71758E219652C, -77, -4 },
16998 { 0x9C40000000000000, -50, 4 },
16999 { 0xE8D4A51000000000, -24, 12 },
17000 { 0xAD78EBC5AC620000, 3, 20 },
17001 { 0x813F3978F8940984, 30, 28 },
17002 { 0xC097CE7BC90715B3, 56, 36 },
17003 { 0x8F7E32CE7BEA5C70, 83, 44 },
17004 { 0xD5D238A4ABE98068, 109, 52 },
17005 { 0x9F4F2726179A2245, 136, 60 },
17006 { 0xED63A231D4C4FB27, 162, 68 },
17007 { 0xB0DE65388CC8ADA8, 189, 76 },
17008 { 0x83C7088E1AAB65DB, 216, 84 },
17009 { 0xC45D1DF942711D9A, 242, 92 },
17010 { 0x924D692CA61BE758, 269, 100 },
17011 { 0xDA01EE641A708DEA, 295, 108 },
17012 { 0xA26DA3999AEF774A, 322, 116 },
17013 { 0xF209787BB47D6B85, 348, 124 },
17014 { 0xB454E4A179DD1877, 375, 132 },
17015 { 0x865B86925B9BC5C2, 402, 140 },
17016 { 0xC83553C5C8965D3D, 428, 148 },
17017 { 0x952AB45CFA97A0B3, 455, 156 },
17018 { 0xDE469FBD99A05FE3, 481, 164 },
17019 { 0xA59BC234DB398C25, 508, 172 },
17020 { 0xF6C69A72A3989F5C, 534, 180 },
17021 { 0xB7DCBF5354E9BECE, 561, 188 },
17022 { 0x88FCF317F22241E2, 588, 196 },
17023 { 0xCC20CE9BD35C78A5, 614, 204 },
17024 { 0x98165AF37B2153DF, 641, 212 },
17025 { 0xE2A0B5DC971F303A, 667, 220 },
17026 { 0xA8D9D1535CE3B396, 694, 228 },
17027 { 0xFB9B7CD9A4A7443C, 720, 236 },
17028 { 0xBB764C4CA7A44410, 747, 244 },
17029 { 0x8BAB8EEFB6409C1A, 774, 252 },
17030 { 0xD01FEF10A657842C, 800, 260 },
17031 { 0x9B10A4E5E9913129, 827, 268 },
17032 { 0xE7109BFBA19C0C9D, 853, 276 },
17033 { 0xAC2820D9623BF429, 880, 284 },
17034 { 0x80444B5E7AA7CF85, 907, 292 },
17035 { 0xBF21E44003ACDD2D, 933, 300 },
17036 { 0x8E679C2F5E44FF8F, 960, 308 },
17037 { 0xD433179D9C8CB841, 986, 316 },
17038 { 0x9E19DB92B4E31BA9, 1013, 324 },
17048 const int f =
kAlpha - e - 1;
17049 const int k = (
f * 78913) / (1 << 18) +
static_cast<int>(
f > 0);
17051 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
17053 JSON_ASSERT(
static_cast<std::size_t
>(index) < kCachedPowers.size());
17055 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
17069 if (n >= 1000000000)
17071 pow10 = 1000000000;
17075 if (n >= 100000000)
17120inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
17121 std::uint64_t rest, std::uint64_t ten_k)
17148 && delta - rest >= ten_k
17149 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
17164 static_assert(
kAlpha >= -60,
"internal error");
17165 static_assert(
kGamma <= -32,
"internal error");
17182 std::uint64_t delta = diyfp::sub(M_plus, M_minus).f;
17183 std::uint64_t dist = diyfp::sub(M_plus, w ).f;
17192 const diyfp one(std::uint64_t{1} << -M_plus.
e, M_plus.
e);
17194 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
17195 std::uint64_t p2 = M_plus.
f & (one.f - 1);
17203 std::uint32_t pow10{};
17231 const std::uint32_t d = p1 / pow10;
17232 const std::uint32_t r = p1 % pow10;
17238 buffer[length++] =
static_cast<char>(
'0' + d);
17257 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
17262 decimal_exponent += n;
17273 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
17274 grisu2_round(buffer, length, dist, delta, rest, ten_n);
17335 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
17337 const std::uint64_t d = p2 >> -one.e;
17338 const std::uint64_t r = p2 & (one.f - 1);
17345 buffer[length++] =
static_cast<char>(
'0' + d);
17370 decimal_exponent -= m;
17378 const std::uint64_t ten_m = one.f;
17402inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
17419 const diyfp c_minus_k(cached.
f, cached.
e);
17422 const diyfp w = diyfp::mul(v, c_minus_k);
17423 const diyfp w_minus = diyfp::mul(m_minus, c_minus_k);
17424 const diyfp w_plus = diyfp::mul(m_plus, c_minus_k);
17447 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
17448 const diyfp M_plus (w_plus.
f - 1, w_plus.
e );
17450 decimal_exponent = -cached.
k;
17460template<
typename FloatType>
17462void
grisu2(
char* buf,
int& len,
int& decimal_exponent, FloatType value)
17464 static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3,
17465 "internal error: not enough precision");
17517 auto k =
static_cast<std::uint32_t
>(e);
17523 *buf++ =
static_cast<char>(
'0' + k);
17527 *buf++ =
static_cast<char>(
'0' + k / 10);
17529 *buf++ =
static_cast<char>(
'0' + k);
17533 *buf++ =
static_cast<char>(
'0' + k / 100);
17535 *buf++ =
static_cast<char>(
'0' + k / 10);
17537 *buf++ =
static_cast<char>(
'0' + k);
17555 int min_exp,
int max_exp)
17561 const int n = len + decimal_exponent;
17567 if (k <= n && n <= max_exp)
17572 std::memset(buf + k,
'0',
static_cast<size_t>(n) -
static_cast<size_t>(k));
17576 return buf + (
static_cast<size_t>(n) + 2);
17579 if (0 < n && n <= max_exp)
17586 std::memmove(buf + (
static_cast<size_t>(n) + 1), buf + n,
static_cast<size_t>(k) -
static_cast<size_t>(n));
17588 return buf + (
static_cast<size_t>(k) + 1U);
17591 if (min_exp < n && n <= 0)
17596 std::memmove(buf + (2 +
static_cast<size_t>(-n)), buf,
static_cast<size_t>(k));
17599 std::memset(buf + 2,
'0',
static_cast<size_t>(-n));
17600 return buf + (2U +
static_cast<size_t>(-n) +
static_cast<size_t>(k));
17615 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
17617 buf += 1 +
static_cast<size_t>(k);
17636template<
typename FloatType>
17639char*
to_chars(
char* first, const
char* last, FloatType value)
17641 static_cast<void>(last);
17645 if (std::signbit(
value))
17652#pragma GCC diagnostic push
17653#pragma GCC diagnostic ignored "-Wfloat-equal"
17664#pragma GCC diagnostic pop
17667 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
17674 int decimal_exponent = 0;
17677 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
17680 constexpr int kMinExp = -4;
17682 constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
17685 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
17686 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
17725template<
typename BasicJsonType>
17733 static constexpr std::uint8_t UTF8_ACCEPT = 0;
17734 static constexpr std::uint8_t UTF8_REJECT = 1;
17745 , loc(
std::localeconv())
17746 , thousands_sep(loc->thousands_sep == nullptr ?
'\0' :
std::char_traits<char>::to_char_type(* (loc->thousands_sep)))
17747 , decimal_point(loc->decimal_point == nullptr ?
'\0' :
std::char_traits<char>::to_char_type(* (loc->decimal_point)))
17748 , indent_char(ichar)
17749 , indent_string(512, indent_char)
17750 , error_handler(error_handler_)
17783 const bool pretty_print,
17784 const bool ensure_ascii,
17785 const unsigned int indent_step,
17786 const unsigned int current_indent = 0)
17788 switch (val.m_type)
17790 case value_t::object:
17792 if (val.m_value.object->empty())
17794 o->write_characters(
"{}", 2);
17800 o->write_characters(
"{\n", 2);
17803 const auto new_indent = current_indent + indent_step;
17806 indent_string.resize(indent_string.size() * 2,
' ');
17810 auto i = val.m_value.object->cbegin();
17811 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
17813 o->write_characters(indent_string.c_str(), new_indent);
17814 o->write_character(
'\"');
17815 dump_escaped(i->first, ensure_ascii);
17816 o->write_characters(
"\": ", 3);
17817 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
17818 o->write_characters(
",\n", 2);
17823 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
17824 o->write_characters(indent_string.c_str(), new_indent);
17825 o->write_character(
'\"');
17826 dump_escaped(i->first, ensure_ascii);
17827 o->write_characters(
"\": ", 3);
17828 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
17830 o->write_character(
'\n');
17831 o->write_characters(indent_string.c_str(), current_indent);
17832 o->write_character(
'}');
17836 o->write_character(
'{');
17839 auto i = val.m_value.object->cbegin();
17840 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
17842 o->write_character(
'\"');
17843 dump_escaped(i->first, ensure_ascii);
17844 o->write_characters(
"\":", 2);
17845 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
17846 o->write_character(
',');
17851 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
17852 o->write_character(
'\"');
17853 dump_escaped(i->first, ensure_ascii);
17854 o->write_characters(
"\":", 2);
17855 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
17857 o->write_character(
'}');
17863 case value_t::array:
17865 if (val.m_value.array->empty())
17867 o->write_characters(
"[]", 2);
17873 o->write_characters(
"[\n", 2);
17876 const auto new_indent = current_indent + indent_step;
17879 indent_string.resize(indent_string.size() * 2,
' ');
17883 for (
auto i = val.m_value.array->cbegin();
17884 i != val.m_value.array->cend() - 1; ++i)
17886 o->write_characters(indent_string.c_str(), new_indent);
17887 dump(*i,
true, ensure_ascii, indent_step, new_indent);
17888 o->write_characters(
",\n", 2);
17893 o->write_characters(indent_string.c_str(), new_indent);
17894 dump(val.m_value.array->back(),
true, ensure_ascii, indent_step, new_indent);
17896 o->write_character(
'\n');
17897 o->write_characters(indent_string.c_str(), current_indent);
17898 o->write_character(
']');
17902 o->write_character(
'[');
17905 for (
auto i = val.m_value.array->cbegin();
17906 i != val.m_value.array->cend() - 1; ++i)
17908 dump(*i,
false, ensure_ascii, indent_step, current_indent);
17909 o->write_character(
',');
17914 dump(val.m_value.array->back(),
false, ensure_ascii, indent_step, current_indent);
17916 o->write_character(
']');
17922 case value_t::string:
17924 o->write_character(
'\"');
17925 dump_escaped(*val.m_value.string, ensure_ascii);
17926 o->write_character(
'\"');
17930 case value_t::binary:
17934 o->write_characters(
"{\n", 2);
17937 const auto new_indent = current_indent + indent_step;
17940 indent_string.resize(indent_string.size() * 2,
' ');
17943 o->write_characters(indent_string.c_str(), new_indent);
17945 o->write_characters(
"\"bytes\": [", 10);
17947 if (!val.m_value.binary->empty())
17949 for (
auto i = val.m_value.binary->cbegin();
17950 i != val.m_value.binary->cend() - 1; ++i)
17953 o->write_characters(
", ", 2);
17955 dump_integer(val.m_value.binary->back());
17958 o->write_characters(
"],\n", 3);
17959 o->write_characters(indent_string.c_str(), new_indent);
17961 o->write_characters(
"\"subtype\": ", 11);
17962 if (val.m_value.binary->has_subtype())
17964 dump_integer(val.m_value.binary->subtype());
17968 o->write_characters(
"null", 4);
17970 o->write_character(
'\n');
17971 o->write_characters(indent_string.c_str(), current_indent);
17972 o->write_character(
'}');
17976 o->write_characters(
"{\"bytes\":[", 10);
17978 if (!val.m_value.binary->empty())
17980 for (
auto i = val.m_value.binary->cbegin();
17981 i != val.m_value.binary->cend() - 1; ++i)
17984 o->write_character(
',');
17986 dump_integer(val.m_value.binary->back());
17989 o->write_characters(
"],\"subtype\":", 12);
17990 if (val.m_value.binary->has_subtype())
17992 dump_integer(val.m_value.binary->subtype());
17993 o->write_character(
'}');
17997 o->write_characters(
"null}", 5);
18003 case value_t::boolean:
18005 if (val.m_value.boolean)
18007 o->write_characters(
"true", 4);
18011 o->write_characters(
"false", 5);
18016 case value_t::number_integer:
18018 dump_integer(val.m_value.number_integer);
18022 case value_t::number_unsigned:
18024 dump_integer(val.m_value.number_unsigned);
18028 case value_t::number_float:
18030 dump_float(val.m_value.number_float);
18034 case value_t::discarded:
18036 o->write_characters(
"<discarded>", 11);
18040 case value_t::null:
18042 o->write_characters(
"null", 4);
18066 void dump_escaped(
const string_t& s,
const bool ensure_ascii)
18068 std::uint32_t codepoint{};
18069 std::uint8_t state = UTF8_ACCEPT;
18070 std::size_t bytes = 0;
18073 std::size_t bytes_after_last_accept = 0;
18074 std::size_t undumped_chars = 0;
18076 for (std::size_t i = 0; i < s.size(); ++i)
18078 const auto byte =
static_cast<std::uint8_t
>(s[i]);
18080 switch (decode(state, codepoint,
byte))
18088 string_buffer[bytes++] =
'\\';
18089 string_buffer[bytes++] =
'b';
18095 string_buffer[bytes++] =
'\\';
18096 string_buffer[bytes++] =
't';
18102 string_buffer[bytes++] =
'\\';
18103 string_buffer[bytes++] =
'n';
18109 string_buffer[bytes++] =
'\\';
18110 string_buffer[bytes++] =
'f';
18116 string_buffer[bytes++] =
'\\';
18117 string_buffer[bytes++] =
'r';
18123 string_buffer[bytes++] =
'\\';
18124 string_buffer[bytes++] =
'\"';
18130 string_buffer[bytes++] =
'\\';
18131 string_buffer[bytes++] =
'\\';
18139 if ((codepoint <= 0x1F) || (ensure_ascii && (codepoint >= 0x7F)))
18141 if (codepoint <= 0xFFFF)
18144 static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 7,
"\\u%04x",
18145 static_cast<std::uint16_t
>(codepoint)));
18151 static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 13,
"\\u%04x\\u%04x",
18152 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
18153 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
18161 string_buffer[bytes++] = s[i];
18170 if (string_buffer.size() - bytes < 13)
18172 o->write_characters(string_buffer.data(), bytes);
18177 bytes_after_last_accept = bytes;
18178 undumped_chars = 0;
18184 switch (error_handler)
18186 case error_handler_t::strict:
18191 case error_handler_t::ignore:
18192 case error_handler_t::replace:
18198 if (undumped_chars > 0)
18205 bytes = bytes_after_last_accept;
18207 if (error_handler == error_handler_t::replace)
18212 string_buffer[bytes++] =
'\\';
18213 string_buffer[bytes++] =
'u';
18214 string_buffer[bytes++] =
'f';
18215 string_buffer[bytes++] =
'f';
18216 string_buffer[bytes++] =
'f';
18217 string_buffer[bytes++] =
'd';
18229 if (string_buffer.size() - bytes < 13)
18231 o->write_characters(string_buffer.data(), bytes);
18235 bytes_after_last_accept = bytes;
18238 undumped_chars = 0;
18241 state = UTF8_ACCEPT;
18256 string_buffer[bytes++] = s[i];
18270 o->write_characters(string_buffer.data(), bytes);
18276 switch (error_handler)
18278 case error_handler_t::strict:
18280 JSON_THROW(type_error::create(316,
concat(
"incomplete UTF-8 string; last byte: 0x", hex_bytes(
static_cast<std::uint8_t
>(s.back() | 0))),
nullptr));
18283 case error_handler_t::ignore:
18286 o->write_characters(string_buffer.data(), bytes_after_last_accept);
18290 case error_handler_t::replace:
18293 o->write_characters(string_buffer.data(), bytes_after_last_accept);
18297 o->write_characters(
"\\ufffd", 6);
18301 o->write_characters(
"\xEF\xBF\xBD", 3);
18323 unsigned int n_digits = 1;
18332 return n_digits + 1;
18336 return n_digits + 2;
18340 return n_digits + 3;
18352 static std::string hex_bytes(std::uint8_t
byte)
18354 std::string result =
"FF";
18355 constexpr const char* nibble_to_hex =
"0123456789ABCDEF";
18356 result[0] = nibble_to_hex[
byte / 16];
18357 result[1] = nibble_to_hex[
byte % 16];
18362 template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
18363 bool is_negative_number(NumberType x)
18368 template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value,
int > = 0 >
18369 bool is_negative_number(NumberType )
18384 std::is_integral<NumberType>::value ||
18385 std::is_same<NumberType, number_unsigned_t>::value ||
18386 std::is_same<NumberType, number_integer_t>::value ||
18387 std::is_same<NumberType, binary_char_t>::value,
18389 void dump_integer(NumberType x)
18391 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
18394 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
18395 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
18396 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
18397 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
18398 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
18399 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
18400 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
18401 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
18402 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
18403 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
18410 o->write_character(
'0');
18415 auto buffer_ptr = number_buffer.begin();
18419 unsigned int n_chars{};
18421 if (is_negative_number(x))
18427 n_chars = 1 + count_digits(abs_value);
18432 n_chars = count_digits(abs_value);
18440 buffer_ptr += n_chars;
18444 while (abs_value >= 100)
18446 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
18448 *(--buffer_ptr) = digits_to_99[digits_index][1];
18449 *(--buffer_ptr) = digits_to_99[digits_index][0];
18452 if (abs_value >= 10)
18454 const auto digits_index =
static_cast<unsigned>(abs_value);
18455 *(--buffer_ptr) = digits_to_99[digits_index][1];
18456 *(--buffer_ptr) = digits_to_99[digits_index][0];
18460 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
18463 o->write_characters(number_buffer.data(), n_chars);
18477 if (!std::isfinite(x))
18479 o->write_characters(
"null", 4);
18488 static constexpr bool is_ieee_single_or_double
18489 = (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 24 && std::numeric_limits<number_float_t>::max_exponent == 128) ||
18490 (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 53 && std::numeric_limits<number_float_t>::max_exponent == 1024);
18492 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
18497 auto* begin = number_buffer.data();
18500 o->write_characters(begin,
static_cast<size_t>(end - begin));
18506 static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
18510 std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(),
"%.*g", d, x);
18515 JSON_ASSERT(
static_cast<std::size_t
>(len) < number_buffer.size());
18518 if (thousands_sep !=
'\0')
18521 const auto end = std::remove(number_buffer.begin(), number_buffer.begin() + len, thousands_sep);
18522 std::fill(end, number_buffer.end(),
'\0');
18523 JSON_ASSERT((end - number_buffer.begin()) <= len);
18524 len = (end - number_buffer.begin());
18528 if (decimal_point !=
'\0' && decimal_point !=
'.')
18531 const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
18532 if (dec_pos != number_buffer.end())
18538 o->write_characters(number_buffer.data(),
static_cast<std::size_t
>(len));
18541 const bool value_is_int_like =
18542 std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
18545 return c ==
'.' || c ==
'e';
18548 if (value_is_int_like)
18550 o->write_characters(
".0", 2);
18575 static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep,
const std::uint8_t
byte)
noexcept
18577 static const std::array<std::uint8_t, 400> utf8d =
18580 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18581 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18582 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18583 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18584 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
18585 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
18586 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
18587 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
18588 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
18589 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
18590 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1,
18591 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
18592 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1,
18593 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
18598 const std::uint8_t type = utf8d[byte];
18600 codep = (state != UTF8_ACCEPT)
18601 ? (
byte & 0x3fu) | (codep << 6u)
18602 : (0xFFu >> type) & (byte);
18604 std::size_t index = 256u +
static_cast<size_t>(state) * 16u +
static_cast<size_t>(type);
18606 state = utf8d[index];
18632 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
18638 output_adapter_t<char> o =
nullptr;
18641 std::array<char, 64> number_buffer{{}};
18644 const std::lconv* loc =
nullptr;
18646 const char thousands_sep =
'\0';
18648 const char decimal_point =
'\0';
18651 std::array<char, 512> string_buffer{{}};
18680#include <functional>
18681#include <initializer_list>
18684#include <stdexcept>
18685#include <type_traits>
18698template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
18699 class Allocator = std::allocator<std::pair<const Key, T>>>
18704 using Container = std::vector<std::pair<const Key, T>, Allocator>;
18709#ifdef JSON_HAS_CPP_14
18719 template <
class It>
18722 ordered_map(std::initializer_list<value_type> init,
const Allocator& alloc = Allocator() )
18727 for (
auto it = this->begin(); it != this->end(); ++it)
18729 if (m_compare(it->first,
key))
18731 return {it,
false};
18734 Container::emplace_back(
key, std::forward<T>(t));
18735 return {std::prev(this->end()),
true};
18742 for (
auto it = this->begin(); it != this->end(); ++it)
18744 if (m_compare(it->first,
key))
18746 return {it,
false};
18749 Container::emplace_back(std::forward<KeyType>(
key), std::forward<T>(t));
18750 return {std::prev(this->end()),
true};
18755 return emplace(
key, T{}).first->second;
18762 return emplace(std::forward<KeyType>(
key), T{}).first->second;
18774 return at(std::forward<KeyType>(
key));
18779 for (
auto it = this->begin(); it != this->end(); ++it)
18781 if (m_compare(it->first,
key))
18787 JSON_THROW(std::out_of_range(
"key not found"));
18794 for (
auto it = this->begin(); it != this->end(); ++it)
18796 if (m_compare(it->first,
key))
18802 JSON_THROW(std::out_of_range(
"key not found"));
18807 for (
auto it = this->begin(); it != this->end(); ++it)
18809 if (m_compare(it->first,
key))
18815 JSON_THROW(std::out_of_range(
"key not found"));
18822 for (
auto it = this->begin(); it != this->end(); ++it)
18824 if (m_compare(it->first,
key))
18830 JSON_THROW(std::out_of_range(
"key not found"));
18835 for (
auto it = this->begin(); it != this->end(); ++it)
18837 if (m_compare(it->first,
key))
18840 for (
auto next = it; ++next != this->end(); ++it)
18845 Container::pop_back();
18856 for (
auto it = this->begin(); it != this->end(); ++it)
18858 if (m_compare(it->first,
key))
18861 for (
auto next = it; ++next != this->end(); ++it)
18866 Container::pop_back();
18875 return erase(pos, std::next(pos));
18885 const auto elements_affected = std::distance(first, last);
18886 const auto offset = std::distance(Container::begin(), first);
18908 for (
auto it = first; std::next(it, elements_affected) != Container::end(); ++it)
18911 new (&*it)
value_type{std::move(*std::next(it, elements_affected))};
18919 Container::resize(this->size() -
static_cast<size_type>(elements_affected));
18928 return Container::begin() + offset;
18933 for (
auto it = this->begin(); it != this->end(); ++it)
18935 if (m_compare(it->first,
key))
18947 for (
auto it = this->begin(); it != this->end(); ++it)
18949 if (m_compare(it->first,
key))
18959 for (
auto it = this->begin(); it != this->end(); ++it)
18961 if (m_compare(it->first,
key))
18966 return Container::end();
18973 for (
auto it = this->begin(); it != this->end(); ++it)
18975 if (m_compare(it->first,
key))
18980 return Container::end();
18985 for (
auto it = this->begin(); it != this->end(); ++it)
18987 if (m_compare(it->first,
key))
18992 return Container::end();
18997 return emplace(value.first, std::move(value.second));
19002 for (
auto it = this->begin(); it != this->end(); ++it)
19004 if (m_compare(it->first, value.first))
19006 return {it,
false};
19009 Container::push_back(value);
19010 return {--this->end(),
true};
19013 template<
typename InputIt>
19014 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
19015 std::input_iterator_tag>::value>::type;
19017 template<
typename InputIt,
typename = require_input_iter<InputIt>>
19020 for (
auto it = first; it != last; ++it)
19033#if defined(JSON_HAS_CPP_17)
19035 #include <string_view>
19070 friend class ::nlohmann::json_pointer;
19074 template<
typename BasicJsonType,
typename InputType>
19075 friend class ::nlohmann::detail::parser;
19076 friend ::nlohmann::detail::serializer<basic_json>;
19077 template<
typename BasicJsonType>
19078 friend class ::nlohmann::detail::iter_impl;
19079 template<
typename BasicJsonType,
typename CharType>
19080 friend class ::nlohmann::detail::binary_writer;
19081 template<
typename BasicJsonType,
typename InputType,
typename SAX>
19082 friend class ::nlohmann::detail::binary_reader;
19083 template<
typename BasicJsonType>
19084 friend class ::nlohmann::detail::json_sax_dom_parser;
19085 template<
typename BasicJsonType>
19086 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
19087 friend class ::nlohmann::detail::exception;
19094 using lexer = ::nlohmann::detail::lexer_base<basic_json>;
19096 template<
typename InputAdapterType>
19097 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
19098 InputAdapterType adapter,
19100 const bool allow_exceptions =
true,
19101 const bool ignore_comments =
false
19104 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
19105 std::move(cb), allow_exceptions, ignore_comments);
19110 template<
typename BasicJsonType>
19112 template<
typename BasicJsonType>
19114 template<
typename Iterator>
19118 template<
typename CharType>
19121 template<
typename InputType>
19123 template<
typename CharType>
using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
19126 using serializer = ::nlohmann::detail::serializer<basic_json>;
19132 template<
typename T,
typename SFINAE>
19189 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
19191 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
19219 result[
"copyright"] =
"(C) 2013-2022 Niels Lohmann";
19220 result[
"name"] =
"JSON for Modern C++";
19221 result[
"url"] =
"https://github.com/nlohmann/json";
19222 result[
"version"][
"string"] =
19231 result[
"platform"] =
"win32";
19232#elif defined __linux__
19233 result[
"platform"] =
"linux";
19234#elif defined __APPLE__
19235 result[
"platform"] =
"apple";
19236#elif defined __unix__
19237 result[
"platform"] =
"unix";
19239 result[
"platform"] =
"unknown";
19242#if defined(__ICC) || defined(__INTEL_COMPILER)
19243 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
19244#elif defined(__clang__)
19245 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
19246#elif defined(__GNUC__) || defined(__GNUG__)
19247 result[
"compiler"] = {{
"family",
"gcc"}, {
"version",
detail::concat(
19253#elif defined(__HP_cc) || defined(__HP_aCC)
19254 result[
"compiler"] =
"hp"
19255#elif defined(__IBMCPP__)
19256 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
19257#elif defined(_MSC_VER)
19258 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
19259#elif defined(__PGI)
19260 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
19261#elif defined(__SUNPRO_CC)
19262 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
19264 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
19268#if defined(_MSVC_LANG)
19270#elif defined(__cplusplus)
19273 result[
"compiler"][
"c++"] =
"unknown";
19292#if defined(JSON_HAS_CPP_14)
19295 using default_object_comparator_t = std::less<>;
19305 AllocatorType<std::pair<
const StringType,
19310 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
19334 using binary_t = nlohmann::byte_container_with_subtype<BinaryType>;
19345 template<
typename T,
typename... Args>
19349 AllocatorType<T> alloc;
19350 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
19352 auto deleter = [&](T * obj)
19354 AllocatorTraits::deallocate(alloc, obj, 1);
19356 std::unique_ptr<T,
decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
19357 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
19359 return obj.release();
19426 case value_t::object:
19428 object = create<object_t>();
19432 case value_t::array:
19434 array = create<array_t>();
19438 case value_t::string:
19440 string = create<string_t>(
"");
19444 case value_t::binary:
19446 binary = create<binary_t>();
19450 case value_t::boolean:
19452 boolean =
static_cast<boolean_t>(
false);
19456 case value_t::number_integer:
19462 case value_t::number_unsigned:
19468 case value_t::number_float:
19474 case value_t::null:
19480 case value_t::discarded:
19486 JSON_THROW(other_error::create(500,
"961c151d2e87f2686a955a9be24d316f1362bf21 3.11.1",
nullptr));
19525 if (t == value_t::array || t == value_t::object)
19528 std::vector<basic_json> stack;
19531 if (t == value_t::array)
19533 stack.reserve(array->size());
19534 std::move(array->begin(), array->end(), std::back_inserter(stack));
19538 stack.reserve(object->size());
19539 for (
auto&& it : *
object)
19541 stack.push_back(std::move(it.second));
19545 while (!stack.empty())
19548 basic_json current_item(std::move(stack.back()));
19555 std::move(current_item.
m_value.array->begin(), current_item.
m_value.array->end(), std::back_inserter(stack));
19557 current_item.
m_value.array->clear();
19561 for (
auto&& it : *current_item.
m_value.object)
19563 stack.push_back(std::move(it.second));
19566 current_item.
m_value.object->clear();
19576 case value_t::object:
19578 AllocatorType<object_t> alloc;
19579 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
object);
19580 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
19584 case value_t::array:
19586 AllocatorType<array_t> alloc;
19587 std::allocator_traits<
decltype(alloc)>::destroy(alloc, array);
19588 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, array, 1);
19592 case value_t::string:
19594 AllocatorType<string_t> alloc;
19595 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
string);
19596 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
19600 case value_t::binary:
19602 AllocatorType<binary_t> alloc;
19603 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
binary);
19604 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
binary, 1);
19608 case value_t::null:
19609 case value_t::boolean:
19610 case value_t::number_integer:
19611 case value_t::number_unsigned:
19612 case value_t::number_float:
19613 case value_t::discarded:
19643 JSON_ASSERT(m_type != value_t::object || m_value.object !=
nullptr);
19644 JSON_ASSERT(m_type != value_t::array || m_value.array !=
nullptr);
19645 JSON_ASSERT(m_type != value_t::string || m_value.string !=
nullptr);
19646 JSON_ASSERT(m_type != value_t::binary || m_value.binary !=
nullptr);
19648#if JSON_DIAGNOSTICS
19652 JSON_ASSERT(!check_parents || !is_structured() || std::all_of(begin(), end(), [
this](
const basic_json & j)
19654 return j.m_parent ==
this;
19659 static_cast<void>(check_parents);
19664#if JSON_DIAGNOSTICS
19667 case value_t::array:
19669 for (
auto& element : *m_value.array)
19671 element.m_parent =
this;
19676 case value_t::object:
19678 for (
auto& element : *m_value.object)
19680 element.second.m_parent =
this;
19685 case value_t::null:
19686 case value_t::string:
19687 case value_t::boolean:
19688 case value_t::number_integer:
19689 case value_t::number_unsigned:
19690 case value_t::number_float:
19691 case value_t::binary:
19692 case value_t::discarded:
19701#if JSON_DIAGNOSTICS
19702 for (
typename iterator::difference_type i = 0; i < count_set_parents; ++i)
19704 (it + i)->m_parent =
this;
19707 static_cast<void>(count_set_parents);
19714#if JSON_DIAGNOSTICS
19715 if (old_capacity !=
static_cast<std::size_t
>(-1))
19729#ifdef JSON_HEDLEY_MSVC_VERSION
19730#pragma warning(push )
19731#pragma warning(disable : 4127)
19738#ifdef JSON_HEDLEY_MSVC_VERSION
19739#pragma warning( pop )
19744 static_cast<void>(j);
19745 static_cast<void>(old_capacity);
19775 : m_type(v), m_value(v)
19777 assert_invariant();
19785 assert_invariant();
19790 template <
typename CompatibleType,
19796 std::forward<CompatibleType>(val))))
19800 assert_invariant();
19805 template <
typename BasicJsonType,
19810 using other_boolean_t =
typename BasicJsonType::boolean_t;
19811 using other_number_float_t =
typename BasicJsonType::number_float_t;
19812 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
19813 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
19814 using other_string_t =
typename BasicJsonType::string_t;
19815 using other_object_t =
typename BasicJsonType::object_t;
19816 using other_array_t =
typename BasicJsonType::array_t;
19817 using other_binary_t =
typename BasicJsonType::binary_t;
19819 switch (val.type())
19821 case value_t::boolean:
19824 case value_t::number_float:
19827 case value_t::number_integer:
19830 case value_t::number_unsigned:
19833 case value_t::string:
19836 case value_t::object:
19839 case value_t::array:
19842 case value_t::binary:
19845 case value_t::null:
19848 case value_t::discarded:
19849 m_type = value_t::discarded;
19856 assert_invariant();
19862 bool type_deduction =
true,
19863 value_t manual_type = value_t::array)
19867 bool is_an_object = std::all_of(init.begin(), init.end(),
19870 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
19874 if (!type_deduction)
19877 if (manual_type == value_t::array)
19879 is_an_object =
false;
19885 JSON_THROW(type_error::create(301,
"cannot create object from initializer list",
nullptr));
19892 m_type = value_t::object;
19893 m_value = value_t::object;
19895 for (
auto& element_ref : init)
19898 m_value.object->emplace(
19899 std::move(*((*element.m_value.array)[0].m_value.string)),
19900 std::move((*element.m_value.array)[1]));
19906 m_type = value_t::array;
19907 m_value.array = create<array_t>(init.begin(), init.end());
19911 assert_invariant();
19920 res.m_type = value_t::binary;
19921 res.m_value = init;
19928 static basic_json binary(
const typename binary_t::container_type& init,
typename binary_t::subtype_type subtype)
19931 res.m_type = value_t::binary;
19932 res.m_value =
binary_t(init, subtype);
19942 res.m_type = value_t::binary;
19943 res.m_value = std::move(init);
19950 static basic_json binary(
typename binary_t::container_type&& init,
typename binary_t::subtype_type subtype)
19953 res.m_type = value_t::binary;
19954 res.m_value =
binary_t(std::move(init), subtype);
19963 return basic_json(init,
false, value_t::array);
19971 return basic_json(init,
false, value_t::object);
19979 m_value.array = create<array_t>(cnt, val);
19981 assert_invariant();
19986 template <
class InputIT,
typename std::enable_if <
19987 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
19988 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >::type = 0 >
19997 JSON_THROW(invalid_iterator::create(201,
"iterators are not compatible",
nullptr));
20001 m_type = first.m_object->m_type;
20006 case value_t::boolean:
20007 case value_t::number_float:
20008 case value_t::number_integer:
20009 case value_t::number_unsigned:
20010 case value_t::string:
20013 || !last.m_it.primitive_iterator.is_end()))
20015 JSON_THROW(invalid_iterator::create(204,
"iterators out of range", first.m_object));
20020 case value_t::null:
20021 case value_t::object:
20022 case value_t::array:
20023 case value_t::binary:
20024 case value_t::discarded:
20031 case value_t::number_integer:
20033 m_value.number_integer = first.m_object->m_value.number_integer;
20037 case value_t::number_unsigned:
20039 m_value.number_unsigned = first.m_object->m_value.number_unsigned;
20043 case value_t::number_float:
20045 m_value.number_float = first.m_object->m_value.number_float;
20049 case value_t::boolean:
20051 m_value.boolean = first.m_object->m_value.boolean;
20055 case value_t::string:
20057 m_value = *first.m_object->m_value.string;
20061 case value_t::object:
20063 m_value.object = create<object_t>(first.m_it.object_iterator,
20064 last.m_it.object_iterator);
20068 case value_t::array:
20070 m_value.array = create<array_t>(first.m_it.array_iterator,
20071 last.m_it.array_iterator);
20075 case value_t::binary:
20077 m_value = *first.m_object->m_value.binary;
20081 case value_t::null:
20082 case value_t::discarded:
20084 JSON_THROW(invalid_iterator::create(206,
detail::concat(
"cannot construct with iterators from ", first.m_object->type_name()), first.m_object));
20088 assert_invariant();
20096 template<
typename JsonRef,
20098 std::is_same<typename JsonRef::value_type, basic_json>>::value,
int> = 0 >
20104 : m_type(other.m_type)
20111 case value_t::object:
20113 m_value = *other.
m_value.object;
20117 case value_t::array:
20119 m_value = *other.
m_value.array;
20123 case value_t::string:
20125 m_value = *other.
m_value.string;
20129 case value_t::boolean:
20131 m_value = other.
m_value.boolean;
20135 case value_t::number_integer:
20137 m_value = other.
m_value.number_integer;
20141 case value_t::number_unsigned:
20143 m_value = other.
m_value.number_unsigned;
20147 case value_t::number_float:
20149 m_value = other.
m_value.number_float;
20153 case value_t::binary:
20155 m_value = *other.
m_value.binary;
20159 case value_t::null:
20160 case value_t::discarded:
20166 assert_invariant();
20172 : m_type(std::move(other.m_type)),
20173 m_value(std::move(other.m_value))
20176 other.assert_invariant(
false);
20179 other.m_type = value_t::null;
20180 other.m_value = {};
20183 assert_invariant();
20189 std::is_nothrow_move_constructible<value_t>::value&&
20190 std::is_nothrow_move_assignable<value_t>::value&&
20191 std::is_nothrow_move_constructible<json_value>::value&&
20192 std::is_nothrow_move_assignable<json_value>::value
20199 swap(m_type, other.m_type);
20200 swap(m_value, other.m_value);
20203 assert_invariant();
20211 assert_invariant(
false);
20212 m_value.destroy(m_type);
20229 const char indent_char =
' ',
20230 const bool ensure_ascii =
false,
20238 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(
indent));
20242 s.dump(*
this,
false, ensure_ascii, 0);
20259 return is_null() || is_string() || is_boolean() || is_number() || is_binary();
20266 return is_array() || is_object();
20273 return m_type == value_t::null;
20280 return m_type == value_t::boolean;
20287 return is_number_integer() || is_number_float();
20294 return m_type == value_t::number_integer || m_type == value_t::number_unsigned;
20301 return m_type == value_t::number_unsigned;
20308 return m_type == value_t::number_float;
20315 return m_type == value_t::object;
20322 return m_type == value_t::array;
20329 return m_type == value_t::string;
20336 return m_type == value_t::binary;
20343 return m_type == value_t::discarded;
20365 return m_value.boolean;
20374 return is_object() ? m_value.object :
nullptr;
20380 return is_object() ? m_value.object :
nullptr;
20386 return is_array() ? m_value.array :
nullptr;
20392 return is_array() ? m_value.array :
nullptr;
20398 return is_string() ? m_value.string :
nullptr;
20404 return is_string() ? m_value.string :
nullptr;
20410 return is_boolean() ? &m_value.boolean :
nullptr;
20416 return is_boolean() ? &m_value.boolean :
nullptr;
20422 return is_number_integer() ? &m_value.number_integer :
nullptr;
20428 return is_number_integer() ? &m_value.number_integer :
nullptr;
20434 return is_number_unsigned() ? &m_value.number_unsigned :
nullptr;
20440 return is_number_unsigned() ? &m_value.number_unsigned :
nullptr;
20446 return is_number_float() ? &m_value.number_float :
nullptr;
20452 return is_number_float() ? &m_value.number_float :
nullptr;
20458 return is_binary() ? m_value.binary :
nullptr;
20464 return is_binary() ? m_value.binary :
nullptr;
20478 template<
typename ReferenceType,
typename ThisType>
20482 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
20489 JSON_THROW(type_error::create(303,
detail::concat(
"incompatible ReferenceType for get_ref, actual type is ", obj.type_name()), &obj));
20499 template<
typename PointerType,
typename std::enable_if<
20500 std::is_pointer<PointerType>::value,
int>::type = 0>
20504 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
20509 template <
typename PointerType,
typename std::enable_if <
20510 std::is_pointer<PointerType>::value&&
20511 std::is_const<typename std::remove_pointer<PointerType>::type>::value,
int >::type = 0 >
20515 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
20557 template <
typename ValueType,
20565 auto ret = ValueType();
20600 template <
typename ValueType,
20625 template <
typename BasicJsonType,
20648 template<
typename BasicJsonType,
20650 std::is_same<BasicJsonType, basic_json_t>::value,
20661 template<
typename PointerType,
20663 std::is_pointer<PointerType>::value,
20666 ->
decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
20669 return get_ptr<PointerType>();
20696 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
20697#if defined(JSON_HAS_CPP_14)
20701 noexcept(
std::declval<const
basic_json_t&>().template get_impl<ValueType>(
detail::priority_tag<4> {})))
20707 static_assert(!std::is_reference<ValueTypeCV>::value,
20708 "get() cannot be used with reference types, you might want to use get_ref()");
20739 template<
typename PointerType,
typename std::enable_if<
20740 std::is_pointer<PointerType>::value,
int>::type = 0>
20744 return get_ptr<PointerType>();
20749 template <
typename ValueType,
20754 ValueType &
get_to(ValueType& v)
const noexcept(
noexcept(
20763 template<
typename ValueType,
20774 typename T, std::size_t N,
20775 typename Array = T (&)[N],
20780 std::declval<const basic_json_t&>(), v)))
20788 template<
typename ReferenceType,
typename std::enable_if<
20789 std::is_reference<ReferenceType>::value,
int>::type = 0>
20793 return get_ref_impl<ReferenceType>(*
this);
20798 template <
typename ReferenceType,
typename std::enable_if <
20799 std::is_reference<ReferenceType>::value&&
20800 std::is_const<typename std::remove_reference<ReferenceType>::type>::value,
int >::type = 0 >
20804 return get_ref_impl<ReferenceType>(*
this);
20836 template <
typename ValueType,
typename std::enable_if <
20844#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
20847#if defined(JSON_HAS_CPP_17)
20851 >::value,
int >::type = 0 >
20855 return get<ValueType>();
20867 return *get_ptr<binary_t*>();
20879 return *get_ptr<const binary_t*>();
20902 return set_parent(m_value.array->at(idx));
20925 return m_value.array->at(idx);
20949 auto it = m_value.object->find(
key);
20950 if (it == m_value.object->end())
20954 return set_parent(it->second);
20969 auto it = m_value.object->find(std::forward<KeyType>(
key));
20970 if (it == m_value.object->end())
20974 return set_parent(it->second);
20987 auto it = m_value.object->find(
key);
20988 if (it == m_value.object->end())
21007 auto it = m_value.object->find(std::forward<KeyType>(
key));
21008 if (it == m_value.object->end())
21022 m_type = value_t::array;
21023 m_value.
array = create<array_t>();
21024 assert_invariant();
21031 if (idx >= m_value.array->size())
21033#if JSON_DIAGNOSTICS
21035 const auto old_size = m_value.array->size();
21036 const auto old_capacity = m_value.array->capacity();
21038 m_value.array->resize(idx + 1);
21040#if JSON_DIAGNOSTICS
21049 set_parents(begin() +
static_cast<typename iterator::difference_type
>(old_size),
static_cast<typename iterator::difference_type
>(idx + 1 - old_size));
21052 assert_invariant();
21055 return m_value.array->operator[](idx);
21058 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a numeric argument with ", type_name()),
this));
21068 return m_value.
array->operator[](idx);
21071 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a numeric argument with ", type_name()),
this));
21081 m_type = value_t::object;
21082 m_value.
object = create<object_t>();
21083 assert_invariant();
21089 auto result = m_value.object->emplace(std::move(
key),
nullptr);
21090 return set_parent(result.first->second);
21093 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
21108 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
21113 template<
typename T>
21116 return operator[](
typename object_t::key_type(
key));
21119 template<
typename T>
21122 return operator[](
typename object_t::key_type(
key));
21134 m_type = value_t::object;
21135 m_value.
object = create<object_t>();
21136 assert_invariant();
21142 auto result = m_value.object->emplace(std::forward<KeyType>(
key),
nullptr);
21143 return set_parent(result.first->second);
21146 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
21158 auto it = m_value.
object->
find(std::forward<KeyType>(
key));
21163 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
21170 std::is_same<KeyType, typename object_t::key_type>::value
21172 && !std::is_same<value_t, ValueType>::value,
int > = 0 >
21173 typename std::decay<ValueType>::type
value(
const KeyType&
key, ValueType && default_value)
const
21179 const auto it = find(
key);
21182 return it->template get<typename std::decay<ValueType>::type>();
21185 return std::forward<ValueType>(default_value);
21204 && !std::is_same<value_t, ValueType>::value,
int > = 0 >
21205 typename std::decay<ValueType>::type
value(
const char*
key, ValueType && default_value)
const
21207 return value(
typename object_t::key_type(
key), std::forward<ValueType>(default_value));
21212 return value(
typename object_t::key_type(
key),
string_t(default_value));
21220 && !std::is_same<value_t, ValueType>::value
21222 typename std::decay<ValueType>::type
value(KeyType &&
key, ValueType && default_value)
const
21228 const auto it = find(std::forward<KeyType>(
key));
21231 return it->template get<typename std::decay<ValueType>::type>();
21234 return std::forward<ValueType>(default_value);
21247 return value(std::forward<KeyType>(
key),
string_t(default_value));
21262 return ptr.
get_checked(
this).template get<ValueType>();
21266 return default_value;
21276 ValueType value(const ::nlohmann::json_pointer<BasicJsonType>& ptr,
const ValueType& default_value)
const
21278 return value(ptr.convert(), default_value);
21287 return value(ptr,
string_t(default_value));
21290 template<
typename BasicJsonType>
21293 string_t value(const typename ::nlohmann::
json_pointer<BasicJsonType>& ptr, const
char* default_value)
const
21295 return value(ptr.convert(), default_value);
21333 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
21334 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
21340 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
21343 IteratorType result = end();
21347 case value_t::boolean:
21348 case value_t::number_float:
21349 case value_t::number_integer:
21350 case value_t::number_unsigned:
21351 case value_t::string:
21352 case value_t::binary:
21356 JSON_THROW(invalid_iterator::create(205,
"iterator out of range",
this));
21361 AllocatorType<string_t> alloc;
21362 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_value.string);
21363 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_value.string, 1);
21364 m_value.string =
nullptr;
21366 else if (is_binary())
21368 AllocatorType<binary_t> alloc;
21369 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_value.binary);
21370 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_value.binary, 1);
21371 m_value.binary =
nullptr;
21374 m_type = value_t::null;
21375 assert_invariant();
21379 case value_t::object:
21381 result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator);
21385 case value_t::array:
21387 result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator);
21391 case value_t::null:
21392 case value_t::discarded:
21403 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
21404 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
21405 IteratorType
erase(IteratorType first, IteratorType last)
21410 JSON_THROW(invalid_iterator::create(203,
"iterators do not fit current value",
this));
21413 IteratorType result = end();
21417 case value_t::boolean:
21418 case value_t::number_float:
21419 case value_t::number_integer:
21420 case value_t::number_unsigned:
21421 case value_t::string:
21422 case value_t::binary:
21425 || !last.m_it.primitive_iterator.is_end()))
21427 JSON_THROW(invalid_iterator::create(204,
"iterators out of range",
this));
21432 AllocatorType<string_t> alloc;
21433 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_value.string);
21434 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_value.string, 1);
21435 m_value.string =
nullptr;
21437 else if (is_binary())
21439 AllocatorType<binary_t> alloc;
21440 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_value.binary);
21441 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_value.binary, 1);
21442 m_value.binary =
nullptr;
21445 m_type = value_t::null;
21446 assert_invariant();
21450 case value_t::object:
21452 result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator,
21453 last.m_it.object_iterator);
21457 case value_t::array:
21459 result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator,
21460 last.m_it.array_iterator);
21464 case value_t::null:
21465 case value_t::discarded:
21484 return m_value.object->erase(std::forward<KeyType>(
key));
21497 const auto it = m_value.object->find(std::forward<KeyType>(
key));
21498 if (it != m_value.object->end())
21500 m_value.object->erase(it);
21514 return erase_internal(
key);
21523 return erase_internal(std::forward<KeyType>(
key));
21538 m_value.array->erase(m_value.array->begin() +
static_cast<difference_type>(idx));
21560 auto result = end();
21564 result.m_it.object_iterator = m_value.object->find(
key);
21574 auto result = cend();
21578 result.m_it.object_iterator = m_value.object->find(
key);
21590 auto result = end();
21594 result.m_it.object_iterator = m_value.object->find(std::forward<KeyType>(
key));
21606 auto result = cend();
21610 result.m_it.object_iterator = m_value.object->find(std::forward<KeyType>(
key));
21621 return is_object() ? m_value.object->count(
key) : 0;
21631 return is_object() ? m_value.object->count(std::forward<KeyType>(
key)) : 0;
21638 return is_object() && m_value.object->find(
key) != m_value.object->end();
21647 return is_object() && m_value.object->find(std::forward<KeyType>(
key)) != m_value.object->end();
21657 template<
typename BasicJsonType>
21659 bool contains(
const typename ::nlohmann::json_pointer<BasicJsonType> ptr)
const
21661 return ptr.contains(
this);
21676 iterator begin() noexcept
21678 iterator result(
this);
21679 result.set_begin();
21685 const_iterator begin() const noexcept
21692 const_iterator cbegin() const noexcept
21694 const_iterator result(
this);
21695 result.set_begin();
21701 iterator end() noexcept
21703 iterator result(
this);
21710 const_iterator end() const noexcept
21717 const_iterator cend() const noexcept
21719 const_iterator result(
this);
21726 reverse_iterator rbegin() noexcept
21728 return reverse_iterator(end());
21733 const_reverse_iterator rbegin() const noexcept
21740 reverse_iterator rend() noexcept
21742 return reverse_iterator(begin());
21747 const_reverse_iterator rend() const noexcept
21754 const_reverse_iterator crbegin() const noexcept
21756 return const_reverse_iterator(cend());
21761 const_reverse_iterator crend() const noexcept
21763 return const_reverse_iterator(cbegin());
21773 static iteration_proxy<iterator> iterator_wrapper(reference ref) noexcept
21775 return ref.items();
21784 static iteration_proxy<const_iterator> iterator_wrapper(const_reference ref) noexcept
21786 return ref.items();
21791 iteration_proxy<iterator> items() noexcept
21793 return iteration_proxy<iterator>(*
this);
21798 iteration_proxy<const_iterator> items() const noexcept
21800 return iteration_proxy<const_iterator>(*
this);
21815 bool empty() const noexcept
21819 case value_t::null:
21825 case value_t::array:
21828 return m_value.array->empty();
21831 case value_t::object:
21834 return m_value.object->empty();
21837 case value_t::string:
21838 case value_t::boolean:
21839 case value_t::number_integer:
21840 case value_t::number_unsigned:
21841 case value_t::number_float:
21842 case value_t::binary:
21843 case value_t::discarded:
21854 size_type size() const noexcept
21858 case value_t::null:
21864 case value_t::array:
21867 return m_value.array->size();
21870 case value_t::object:
21873 return m_value.object->size();
21876 case value_t::string:
21877 case value_t::boolean:
21878 case value_t::number_integer:
21879 case value_t::number_unsigned:
21880 case value_t::number_float:
21881 case value_t::binary:
21882 case value_t::discarded:
21893 size_type max_size() const noexcept
21897 case value_t::array:
21900 return m_value.array->max_size();
21903 case value_t::object:
21906 return m_value.object->max_size();
21909 case value_t::null:
21910 case value_t::string:
21911 case value_t::boolean:
21912 case value_t::number_integer:
21913 case value_t::number_unsigned:
21914 case value_t::number_float:
21915 case value_t::binary:
21916 case value_t::discarded:
21937 void clear() noexcept
21941 case value_t::number_integer:
21943 m_value.number_integer = 0;
21947 case value_t::number_unsigned:
21949 m_value.number_unsigned = 0;
21953 case value_t::number_float:
21955 m_value.number_float = 0.0;
21959 case value_t::boolean:
21961 m_value.boolean =
false;
21965 case value_t::string:
21967 m_value.string->clear();
21971 case value_t::binary:
21973 m_value.binary->clear();
21977 case value_t::array:
21979 m_value.array->clear();
21983 case value_t::object:
21985 m_value.object->clear();
21989 case value_t::null:
21990 case value_t::discarded:
22009 m_type = value_t::array;
22010 m_value = value_t::array;
22011 assert_invariant();
22015 const auto old_capacity = m_value.array->capacity();
22016 m_value.array->push_back(std::move(val));
22017 set_parent(m_value.array->back(), old_capacity);
22025 push_back(std::move(val));
22042 m_type = value_t::array;
22043 m_value = value_t::array;
22044 assert_invariant();
22048 const auto old_capacity = m_value.array->capacity();
22049 m_value.array->push_back(val);
22050 set_parent(m_value.array->back(), old_capacity);
22074 m_type = value_t::object;
22075 m_value = value_t::object;
22076 assert_invariant();
22080 auto res = m_value.object->insert(val);
22081 set_parent(res.first->second);
22096 if (is_object() && init.size() == 2 && (*init.begin())->is_string())
22099 push_back(
typename object_t::value_type(
22100 std::move(
key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
22118 template<
class... Args>
22130 m_type = value_t::array;
22131 m_value = value_t::array;
22132 assert_invariant();
22136 const auto old_capacity = m_value.array->capacity();
22137 m_value.array->emplace_back(std::forward<Args>(args)...);
22138 return set_parent(m_value.array->back(), old_capacity);
22143 template<
class... Args>
22155 m_type = value_t::object;
22156 m_value = value_t::object;
22157 assert_invariant();
22161 auto res = m_value.object->emplace(std::forward<Args>(args)...);
22162 set_parent(res.first->second);
22166 it.m_it.object_iterator = res.first;
22169 return {it, res.second};
22175 template<
typename... Args>
22181 auto insert_pos = std::distance(m_value.array->begin(), pos.m_it.array_iterator);
22182 m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
22183 result.m_it.array_iterator = m_value.array->begin() + insert_pos;
22203 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22207 return insert_iterator(pos, val);
22217 return insert(pos, val);
22230 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22234 return insert_iterator(pos, cnt, val);
22253 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22259 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
22264 JSON_THROW(invalid_iterator::create(211,
"passed iterators may not belong to container",
this));
22268 return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
22284 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22288 return insert_iterator(pos, ilist.begin(), ilist.end());
22304 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
22310 JSON_THROW(invalid_iterator::create(202,
"iterators first and last must point to objects",
this));
22313 m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
22320 update(j.begin(), j.end(), merge_objects);
22330 m_type = value_t::object;
22331 m_value.object = create<object_t>();
22332 assert_invariant();
22343 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
22349 JSON_THROW(type_error::create(312,
detail::concat(
"cannot use update() with ", first.m_object->type_name()), first.m_object));
22352 for (
auto it = first; it != last; ++it)
22354 if (merge_objects && it.value().is_object())
22356 auto it2 = m_value.object->find(it.key());
22357 if (it2 != m_value.object->end())
22359 it2->second.update(it.value(),
true);
22363 m_value.object->operator[](it.key()) = it.value();
22364#if JSON_DIAGNOSTICS
22365 m_value.object->operator[](it.key()).m_parent =
this;
22373 std::is_nothrow_move_constructible<value_t>::value&&
22374 std::is_nothrow_move_assignable<value_t>::value&&
22375 std::is_nothrow_move_constructible<json_value>::value&&
22376 std::is_nothrow_move_assignable<json_value>::value
22383 other.set_parents();
22384 assert_invariant();
22390 std::is_nothrow_move_constructible<value_t>::value&&
22391 std::is_nothrow_move_assignable<value_t>::value&&
22392 std::is_nothrow_move_constructible<json_value>::value&&
22393 std::is_nothrow_move_assignable<json_value>::value
22407 swap(*(m_value.array), other);
22423 swap(*(m_value.object), other);
22439 swap(*(m_value.string), other);
22455 swap(*(m_value.binary), other);
22465 void swap(
typename binary_t::container_type& other)
22471 swap(*(m_value.binary), other);
22475 JSON_THROW(type_error::create(310,
detail::concat(
"cannot use swap(binary_t::container_type&) with ", type_name()),
this));
22490#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \
22491 const auto lhs_type = lhs.type(); \
22492 const auto rhs_type = rhs.type(); \
22494 if (lhs_type == rhs_type) \
22496 switch (lhs_type) \
22498 case value_t::array: \
22499 return (*lhs.m_value.array) op (*rhs.m_value.array); \
22501 case value_t::object: \
22502 return (*lhs.m_value.object) op (*rhs.m_value.object); \
22504 case value_t::null: \
22505 return (null_result); \
22507 case value_t::string: \
22508 return (*lhs.m_value.string) op (*rhs.m_value.string); \
22510 case value_t::boolean: \
22511 return (lhs.m_value.boolean) op (rhs.m_value.boolean); \
22513 case value_t::number_integer: \
22514 return (lhs.m_value.number_integer) op (rhs.m_value.number_integer); \
22516 case value_t::number_unsigned: \
22517 return (lhs.m_value.number_unsigned) op (rhs.m_value.number_unsigned); \
22519 case value_t::number_float: \
22520 return (lhs.m_value.number_float) op (rhs.m_value.number_float); \
22522 case value_t::binary: \
22523 return (*lhs.m_value.binary) op (*rhs.m_value.binary); \
22525 case value_t::discarded: \
22527 return (unordered_result); \
22530 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \
22532 return static_cast<number_float_t>(lhs.m_value.number_integer) op rhs.m_value.number_float; \
22534 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \
22536 return lhs.m_value.number_float op static_cast<number_float_t>(rhs.m_value.number_integer); \
22538 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \
22540 return static_cast<number_float_t>(lhs.m_value.number_unsigned) op rhs.m_value.number_float; \
22542 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \
22544 return lhs.m_value.number_float op static_cast<number_float_t>(rhs.m_value.number_unsigned); \
22546 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \
22548 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) op rhs.m_value.number_integer; \
22550 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \
22552 return lhs.m_value.number_integer op static_cast<number_integer_t>(rhs.m_value.number_unsigned); \
22554 else if(compares_unordered(lhs, rhs))\
22556 return (unordered_result);\
22559 return (default_result);
22574#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
22577 static_cast<void>(inverse);
22583 bool compares_unordered(const_reference rhs,
bool inverse =
false) const noexcept
22585 return compares_unordered(*
this, rhs, inverse);
22589#if JSON_HAS_THREE_WAY_COMPARISON
22592 bool operator==(const_reference rhs)
const noexcept
22595#pragma GCC diagnostic push
22596#pragma GCC diagnostic ignored "-Wfloat-equal"
22598 const_reference lhs = *
this;
22601#pragma GCC diagnostic pop
22607 template<
typename ScalarType>
22608 requires std::is_scalar_v<ScalarType>
22609 bool operator==(ScalarType rhs)
const noexcept
22616 bool operator!=(const_reference rhs)
const noexcept
22618 if (compares_unordered(rhs,
true))
22627 std::partial_ordering operator<=>(const_reference rhs)
const noexcept
22629 const_reference lhs = *
this;
22633 std::partial_ordering::equivalent,
22634 std::partial_ordering::unordered,
22635 lhs_type <=> rhs_type)
22640 template<
typename ScalarType>
22641 requires std::is_scalar_v<ScalarType>
22642 std::partial_ordering operator<=>(ScalarType rhs)
const noexcept
22647#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
22654 bool operator<=(const_reference rhs)
const noexcept
22656 if (compares_unordered(rhs,
true))
22660 return !(rhs < *
this);
22665 template<
typename ScalarType>
22666 requires std::is_scalar_v<ScalarType>
22667 bool operator<=(ScalarType rhs)
const noexcept
22675 bool operator>=(const_reference rhs)
const noexcept
22677 if (compares_unordered(rhs,
true))
22681 return !(*
this < rhs);
22686 template<
typename ScalarType>
22687 requires std::is_scalar_v<ScalarType>
22688 bool operator>=(ScalarType rhs)
const noexcept
22696 friend bool operator==(const_reference lhs, const_reference rhs)
noexcept
22699#pragma GCC diagnostic push
22700#pragma GCC diagnostic ignored "-Wfloat-equal"
22704#pragma GCC diagnostic pop
22710 template<
typename ScalarType,
typename std::enable_if<
22711 std::is_scalar<ScalarType>::value,
int>::type = 0>
22712 friend bool operator==(const_reference lhs, ScalarType rhs)
noexcept
22719 template<
typename ScalarType,
typename std::enable_if<
22720 std::is_scalar<ScalarType>::value,
int>::type = 0>
22721 friend bool operator==(ScalarType lhs, const_reference rhs)
noexcept
22728 friend bool operator!=(const_reference lhs, const_reference rhs)
noexcept
22730 if (compares_unordered(lhs, rhs,
true))
22734 return !(lhs == rhs);
22739 template<
typename ScalarType,
typename std::enable_if<
22740 std::is_scalar<ScalarType>::value,
int>::type = 0>
22741 friend bool operator!=(const_reference lhs, ScalarType rhs)
noexcept
22748 template<
typename ScalarType,
typename std::enable_if<
22749 std::is_scalar<ScalarType>::value,
int>::type = 0>
22750 friend bool operator!=(ScalarType lhs, const_reference rhs)
noexcept
22757 friend bool operator<(const_reference lhs, const_reference rhs)
noexcept
22767 template<
typename ScalarType,
typename std::enable_if<
22768 std::is_scalar<ScalarType>::value,
int>::type = 0>
22769 friend bool operator<(const_reference lhs, ScalarType rhs)
noexcept
22776 template<
typename ScalarType,
typename std::enable_if<
22777 std::is_scalar<ScalarType>::value,
int>::type = 0>
22778 friend bool operator<(ScalarType lhs, const_reference rhs)
noexcept
22785 friend bool operator<=(const_reference lhs, const_reference rhs)
noexcept
22787 if (compares_unordered(lhs, rhs,
true))
22791 return !(rhs < lhs);
22796 template<
typename ScalarType,
typename std::enable_if<
22797 std::is_scalar<ScalarType>::value,
int>::type = 0>
22798 friend bool operator<=(const_reference lhs, ScalarType rhs)
noexcept
22805 template<
typename ScalarType,
typename std::enable_if<
22806 std::is_scalar<ScalarType>::value,
int>::type = 0>
22807 friend bool operator<=(ScalarType lhs, const_reference rhs)
noexcept
22814 friend bool operator>(const_reference lhs, const_reference rhs)
noexcept
22817 if (compares_unordered(lhs, rhs))
22821 return !(lhs <= rhs);
22826 template<
typename ScalarType,
typename std::enable_if<
22827 std::is_scalar<ScalarType>::value,
int>::type = 0>
22828 friend bool operator>(const_reference lhs, ScalarType rhs)
noexcept
22835 template<
typename ScalarType,
typename std::enable_if<
22836 std::is_scalar<ScalarType>::value,
int>::type = 0>
22837 friend bool operator>(ScalarType lhs, const_reference rhs)
noexcept
22844 friend bool operator>=(const_reference lhs, const_reference rhs)
noexcept
22846 if (compares_unordered(lhs, rhs,
true))
22850 return !(lhs < rhs);
22855 template<
typename ScalarType,
typename std::enable_if<
22856 std::is_scalar<ScalarType>::value,
int>::type = 0>
22857 friend bool operator>=(const_reference lhs, ScalarType rhs)
noexcept
22864 template<
typename ScalarType,
typename std::enable_if<
22865 std::is_scalar<ScalarType>::value,
int>::type = 0>
22866 friend bool operator>=(ScalarType lhs, const_reference rhs)
noexcept
22872#undef JSON_IMPLEMENT_OPERATOR
22885 friend std::ostream& operator<<(std::ostream& o,
const basic_json& j)
22888 const bool pretty_print = o.width() > 0;
22889 const auto indentation = pretty_print ? o.width() : 0;
22896 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
22907 friend std::ostream& operator>>(
const basic_json& j, std::ostream& o)
22924 template<
typename InputType>
22928 const bool allow_exceptions =
true,
22929 const bool ignore_comments =
false)
22932 parser(
detail::input_adapter(std::forward<InputType>(i)), cb, allow_exceptions, ignore_comments).parse(
true, result);
22938 template<
typename IteratorType>
22943 const bool allow_exceptions =
true,
22944 const bool ignore_comments =
false)
22947 parser(
detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).parse(
true, result);
22955 const bool allow_exceptions =
true,
22956 const bool ignore_comments =
false)
22959 parser(i.get(), cb, allow_exceptions, ignore_comments).parse(
true, result);
22965 template<
typename InputType>
22966 static bool accept(InputType&& i,
22967 const bool ignore_comments =
false)
22969 return parser(
detail::input_adapter(std::forward<InputType>(i)),
nullptr,
false, ignore_comments).accept(
true);
22974 template<
typename IteratorType>
22975 static bool accept(IteratorType first, IteratorType last,
22976 const bool ignore_comments =
false)
22978 return parser(
detail::input_adapter(std::move(first), std::move(last)),
nullptr,
false, ignore_comments).accept(
true);
22984 const bool ignore_comments =
false)
22986 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
22991 template <
typename InputType,
typename SAX>
22993 static
bool sax_parse(InputType&& i, SAX* sax,
22995 const
bool strict = true,
22996 const
bool ignore_comments = false)
23000 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23006 template<
class IteratorType,
class SAX>
23008 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
23010 const
bool strict = true,
23011 const
bool ignore_comments = false)
23015 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23024 template <
typename SAX>
23027 static
bool sax_parse(
detail::span_input_adapter&& i, SAX* sax,
23029 const
bool strict = true,
23030 const
bool ignore_comments = false)
23035 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23049 return operator>>(i, j);
23073 case value_t::null:
23075 case value_t::object:
23077 case value_t::array:
23079 case value_t::string:
23081 case value_t::boolean:
23083 case value_t::binary:
23085 case value_t::discarded:
23086 return "discarded";
23087 case value_t::number_integer:
23088 case value_t::number_unsigned:
23089 case value_t::number_float:
23102 value_t m_type = value_t::null;
23105 json_value m_value = {};
23107#if JSON_DIAGNOSTICS
23124 std::vector<std::uint8_t> result;
23125 to_cbor(j, result);
23147 std::vector<std::uint8_t> result;
23148 to_msgpack(j, result);
23169 const bool use_size =
false,
23170 const bool use_type =
false)
23172 std::vector<std::uint8_t> result;
23173 to_ubjson(j, result, use_size, use_type);
23180 const bool use_size =
false,
const bool use_type =
false)
23188 const bool use_size =
false,
const bool use_type =
false)
23196 const bool use_size =
false,
23197 const bool use_type =
false)
23199 std::vector<std::uint8_t> result;
23200 to_bjdata(j, result, use_size, use_type);
23207 const bool use_size =
false,
const bool use_type =
false)
23215 const bool use_size =
false,
const bool use_type =
false)
23224 std::vector<std::uint8_t> result;
23225 to_bson(j, result);
23245 template<
typename InputType>
23248 const bool strict =
true,
23249 const bool allow_exceptions =
true,
23255 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23256 return res ? result :
basic_json(value_t::discarded);
23261 template<
typename IteratorType>
23264 const bool strict =
true,
23265 const bool allow_exceptions =
true,
23271 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23272 return res ? result :
basic_json(value_t::discarded);
23275 template<
typename T>
23279 const
bool strict = true,
23280 const
bool allow_exceptions = true,
23283 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
23290 const
bool strict = true,
23291 const
bool allow_exceptions = true,
23298 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23299 return res ? result :
basic_json(value_t::discarded);
23304 template<
typename InputType>
23307 const bool strict =
true,
23308 const bool allow_exceptions =
true)
23313 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23314 return res ? result :
basic_json(value_t::discarded);
23319 template<
typename IteratorType>
23322 const bool strict =
true,
23323 const bool allow_exceptions =
true)
23328 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23329 return res ? result :
basic_json(value_t::discarded);
23332 template<
typename T>
23336 const
bool strict = true,
23337 const
bool allow_exceptions = true)
23339 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
23345 const
bool strict = true,
23346 const
bool allow_exceptions = true)
23352 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23353 return res ? result :
basic_json(value_t::discarded);
23358 template<
typename InputType>
23361 const bool strict =
true,
23362 const bool allow_exceptions =
true)
23367 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23368 return res ? result :
basic_json(value_t::discarded);
23373 template<
typename IteratorType>
23376 const bool strict =
true,
23377 const bool allow_exceptions =
true)
23382 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23383 return res ? result :
basic_json(value_t::discarded);
23386 template<
typename T>
23390 const
bool strict = true,
23391 const
bool allow_exceptions = true)
23393 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
23399 const
bool strict = true,
23400 const
bool allow_exceptions = true)
23406 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23407 return res ? result :
basic_json(value_t::discarded);
23413 template<
typename InputType>
23416 const bool strict =
true,
23417 const bool allow_exceptions =
true)
23422 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
23423 return res ? result :
basic_json(value_t::discarded);
23428 template<
typename IteratorType>
23431 const bool strict =
true,
23432 const bool allow_exceptions =
true)
23437 const bool res =
binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
23438 return res ? result :
basic_json(value_t::discarded);
23443 template<
typename InputType>
23446 const bool strict =
true,
23447 const bool allow_exceptions =
true)
23453 return res ? result :
basic_json(value_t::discarded);
23458 template<
typename IteratorType>
23461 const bool strict =
true,
23462 const bool allow_exceptions =
true)
23468 return res ? result :
basic_json(value_t::discarded);
23471 template<
typename T>
23475 const
bool strict = true,
23476 const
bool allow_exceptions = true)
23478 return from_bson(ptr, ptr + len, strict, allow_exceptions);
23484 const
bool strict = true,
23485 const
bool allow_exceptions = true)
23492 return res ? result :
basic_json(value_t::discarded);
23510 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23512 reference operator[](const ::nlohmann::json_pointer<BasicJsonType>& ptr)
23514 return ptr.get_unchecked(
this);
23524 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23526 const_reference operator[](const ::nlohmann::json_pointer<BasicJsonType>& ptr)
const
23528 return ptr.get_unchecked(
this);
23538 template<
typename BasicJsonType>
23540 reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr)
23542 return ptr.get_checked(
this);
23552 template<
typename BasicJsonType>
23554 const_reference at(const ::nlohmann::json_pointer<BasicJsonType>& ptr)
const
23556 return ptr.get_checked(
this);
23586 void patch_inplace(
const basic_json& json_patch)
23590 enum class patch_operations {add, remove,
replace, move, copy, test, invalid};
23592 const auto get_op = [](
const std::string & op)
23596 return patch_operations::add;
23598 if (op ==
"remove")
23600 return patch_operations::remove;
23602 if (op ==
"replace")
23604 return patch_operations::replace;
23608 return patch_operations::move;
23612 return patch_operations::copy;
23616 return patch_operations::test;
23619 return patch_operations::invalid;
23634 if (top_pointer != ptr)
23636 result.
at(top_pointer);
23640 const auto last_path = ptr.
back();
23645 switch (parent.m_type)
23647 case value_t::null:
23648 case value_t::object:
23651 parent[last_path] = val;
23655 case value_t::array:
23657 if (last_path ==
"-")
23664 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
23672 parent.
insert(parent.begin() +
static_cast<difference_type
>(idx), val);
23678 case value_t::string:
23679 case value_t::boolean:
23680 case value_t::number_integer:
23681 case value_t::number_unsigned:
23682 case value_t::number_float:
23683 case value_t::binary:
23684 case value_t::discarded:
23691 const auto operation_remove = [
this, &result](
json_pointer & ptr)
23694 const auto last_path = ptr.
back();
23702 auto it = parent.
find(last_path);
23715 parent.
erase(json_pointer::template array_index<basic_json_t>(last_path));
23722 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &json_patch));
23726 for (
const auto& val : json_patch)
23729 const auto get_value = [&val](
const std::string & op,
23730 const std::string & member,
23734 auto it = val.
m_value.object->find(member);
23737 const auto error_msg = (op ==
"op") ?
"operation" :
detail::concat(
"operation '", op,
'\'');
23750 JSON_THROW(parse_error::create(105, 0,
detail::concat(error_msg,
" must have string member '", member,
"'"), &val));
23760 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &val));
23764 const auto op = get_value(
"op",
"op",
true).template get<std::string>();
23765 const auto path = get_value(op,
"path",
true).template get<std::string>();
23768 switch (get_op(op))
23770 case patch_operations::add:
23772 operation_add(ptr, get_value(
"add",
"value",
false));
23776 case patch_operations::remove:
23778 operation_remove(ptr);
23782 case patch_operations::replace:
23785 result.
at(ptr) = get_value(
"replace",
"value",
false);
23789 case patch_operations::move:
23791 const auto from_path = get_value(
"move",
"from",
true).template get<std::string>();
23801 operation_remove(from_ptr);
23802 operation_add(ptr, v);
23806 case patch_operations::copy:
23808 const auto from_path = get_value(
"copy",
"from",
true).template get<std::string>();
23817 operation_add(ptr, v);
23821 case patch_operations::test:
23823 bool success =
false;
23828 success = (result.
at(ptr) == get_value(
"test",
"value",
false));
23844 case patch_operations::invalid:
23860 result.patch_inplace(json_patch);
23868 const std::string& path =
"")
23874 if (source == target)
23879 if (source.
type() != target.
type())
23884 {
"op",
"replace"}, {
"path", path}, {
"value", target}
23889 switch (source.
type())
23891 case value_t::array:
23895 while (i < source.size() && i < target.size())
23899 result.
insert(result.end(), temp_diff.begin(), temp_diff.end());
23908 while (i < source.size())
23912 result.
insert(result.begin() + end_index, object(
23921 while (i < target.size())
23927 {
"value", target[i]}
23935 case value_t::object:
23938 for (
auto it = source.cbegin(); it != source.cend(); ++it)
23943 if (target.
find(it.key()) != target.end())
23946 auto temp_diff = diff(it.value(), target[it.key()], path_key);
23947 result.
insert(result.end(), temp_diff.begin(), temp_diff.end());
23954 {
"op",
"remove"}, {
"path", path_key}
23960 for (
auto it = target.cbegin(); it != target.cend(); ++it)
23962 if (source.
find(it.key()) == source.end())
23968 {
"op",
"add"}, {
"path", path_key},
23969 {
"value", it.value()}
23977 case value_t::null:
23978 case value_t::string:
23979 case value_t::boolean:
23980 case value_t::number_integer:
23981 case value_t::number_unsigned:
23982 case value_t::number_float:
23983 case value_t::binary:
23984 case value_t::discarded:
23990 {
"op",
"replace"}, {
"path", path}, {
"value", target}
24017 for (
auto it = apply_patch.begin(); it != apply_patch.end(); ++it)
24019 if (it.value().is_null())
24025 operator[](it.key()).merge_patch(it.value());
24031 *
this = apply_patch;
24048inline namespace json_literals
24054inline nlohmann::
json operator "" _json(const
char* s,
std::
size_t n)
24056 return nlohmann::json::parse(s, s + n);
24064 return nlohmann::json::json_pointer(std::string(s, n));
24100#if JSON_HAS_THREE_WAY_COMPARISON
24101 return std::is_lt(lhs <=> rhs);
24109#ifndef JSON_HAS_CPP_20
24115 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
24116 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
24125#if JSON_USE_GLOBAL_UDLS
24126 using nlohmann::literals::json_literals::operator
"" _json;
24127 using nlohmann::literals::json_literals::operator
"" _json_pointer;
24142#if defined(__clang__)
24143 #pragma clang diagnostic pop
24148#undef JSON_INTERNAL_CATCH
24150#undef JSON_PRIVATE_UNLESS_TESTED
24151#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
24152#undef NLOHMANN_BASIC_JSON_TPL
24153#undef JSON_EXPLICIT
24154#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
24155#undef JSON_INLINE_VARIABLE
24156#undef JSON_NO_UNIQUE_ADDRESS
24157#undef JSON_DISABLE_ENUM_SERIALIZATION
24158#undef JSON_USE_GLOBAL_UDLS
24160#ifndef JSON_TEST_KEEP_MACROS
24163 #undef JSON_HAS_CPP_11
24164 #undef JSON_HAS_CPP_14
24165 #undef JSON_HAS_CPP_17
24166 #undef JSON_HAS_CPP_20
24167 #undef JSON_HAS_FILESYSTEM
24168 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
24169 #undef JSON_HAS_THREE_WAY_COMPARISON
24170 #undef JSON_HAS_RANGES
24171 #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
24185#undef JSON_HEDLEY_ALWAYS_INLINE
24186#undef JSON_HEDLEY_ARM_VERSION
24187#undef JSON_HEDLEY_ARM_VERSION_CHECK
24188#undef JSON_HEDLEY_ARRAY_PARAM
24189#undef JSON_HEDLEY_ASSUME
24190#undef JSON_HEDLEY_BEGIN_C_DECLS
24191#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
24192#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
24193#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
24194#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
24195#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
24196#undef JSON_HEDLEY_CLANG_HAS_FEATURE
24197#undef JSON_HEDLEY_CLANG_HAS_WARNING
24198#undef JSON_HEDLEY_COMPCERT_VERSION
24199#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
24200#undef JSON_HEDLEY_CONCAT
24201#undef JSON_HEDLEY_CONCAT3
24202#undef JSON_HEDLEY_CONCAT3_EX
24203#undef JSON_HEDLEY_CONCAT_EX
24204#undef JSON_HEDLEY_CONST
24205#undef JSON_HEDLEY_CONSTEXPR
24206#undef JSON_HEDLEY_CONST_CAST
24207#undef JSON_HEDLEY_CPP_CAST
24208#undef JSON_HEDLEY_CRAY_VERSION
24209#undef JSON_HEDLEY_CRAY_VERSION_CHECK
24210#undef JSON_HEDLEY_C_DECL
24211#undef JSON_HEDLEY_DEPRECATED
24212#undef JSON_HEDLEY_DEPRECATED_FOR
24213#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
24214#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
24215#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
24216#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
24217#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
24218#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
24219#undef JSON_HEDLEY_DIAGNOSTIC_POP
24220#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
24221#undef JSON_HEDLEY_DMC_VERSION
24222#undef JSON_HEDLEY_DMC_VERSION_CHECK
24223#undef JSON_HEDLEY_EMPTY_BASES
24224#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
24225#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
24226#undef JSON_HEDLEY_END_C_DECLS
24227#undef JSON_HEDLEY_FLAGS
24228#undef JSON_HEDLEY_FLAGS_CAST
24229#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
24230#undef JSON_HEDLEY_GCC_HAS_BUILTIN
24231#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
24232#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
24233#undef JSON_HEDLEY_GCC_HAS_EXTENSION
24234#undef JSON_HEDLEY_GCC_HAS_FEATURE
24235#undef JSON_HEDLEY_GCC_HAS_WARNING
24236#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
24237#undef JSON_HEDLEY_GCC_VERSION
24238#undef JSON_HEDLEY_GCC_VERSION_CHECK
24239#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
24240#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
24241#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
24242#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
24243#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
24244#undef JSON_HEDLEY_GNUC_HAS_FEATURE
24245#undef JSON_HEDLEY_GNUC_HAS_WARNING
24246#undef JSON_HEDLEY_GNUC_VERSION
24247#undef JSON_HEDLEY_GNUC_VERSION_CHECK
24248#undef JSON_HEDLEY_HAS_ATTRIBUTE
24249#undef JSON_HEDLEY_HAS_BUILTIN
24250#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
24251#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
24252#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
24253#undef JSON_HEDLEY_HAS_EXTENSION
24254#undef JSON_HEDLEY_HAS_FEATURE
24255#undef JSON_HEDLEY_HAS_WARNING
24256#undef JSON_HEDLEY_IAR_VERSION
24257#undef JSON_HEDLEY_IAR_VERSION_CHECK
24258#undef JSON_HEDLEY_IBM_VERSION
24259#undef JSON_HEDLEY_IBM_VERSION_CHECK
24260#undef JSON_HEDLEY_IMPORT
24261#undef JSON_HEDLEY_INLINE
24262#undef JSON_HEDLEY_INTEL_CL_VERSION
24263#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
24264#undef JSON_HEDLEY_INTEL_VERSION
24265#undef JSON_HEDLEY_INTEL_VERSION_CHECK
24266#undef JSON_HEDLEY_IS_CONSTANT
24267#undef JSON_HEDLEY_IS_CONSTEXPR_
24268#undef JSON_HEDLEY_LIKELY
24269#undef JSON_HEDLEY_MALLOC
24270#undef JSON_HEDLEY_MCST_LCC_VERSION
24271#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
24272#undef JSON_HEDLEY_MESSAGE
24273#undef JSON_HEDLEY_MSVC_VERSION
24274#undef JSON_HEDLEY_MSVC_VERSION_CHECK
24275#undef JSON_HEDLEY_NEVER_INLINE
24276#undef JSON_HEDLEY_NON_NULL
24277#undef JSON_HEDLEY_NO_ESCAPE
24278#undef JSON_HEDLEY_NO_RETURN
24279#undef JSON_HEDLEY_NO_THROW
24280#undef JSON_HEDLEY_NULL
24281#undef JSON_HEDLEY_PELLES_VERSION
24282#undef JSON_HEDLEY_PELLES_VERSION_CHECK
24283#undef JSON_HEDLEY_PGI_VERSION
24284#undef JSON_HEDLEY_PGI_VERSION_CHECK
24285#undef JSON_HEDLEY_PREDICT
24286#undef JSON_HEDLEY_PRINTF_FORMAT
24287#undef JSON_HEDLEY_PRIVATE
24288#undef JSON_HEDLEY_PUBLIC
24289#undef JSON_HEDLEY_PURE
24290#undef JSON_HEDLEY_REINTERPRET_CAST
24291#undef JSON_HEDLEY_REQUIRE
24292#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
24293#undef JSON_HEDLEY_REQUIRE_MSG
24294#undef JSON_HEDLEY_RESTRICT
24295#undef JSON_HEDLEY_RETURNS_NON_NULL
24296#undef JSON_HEDLEY_SENTINEL
24297#undef JSON_HEDLEY_STATIC_ASSERT
24298#undef JSON_HEDLEY_STATIC_CAST
24299#undef JSON_HEDLEY_STRINGIFY
24300#undef JSON_HEDLEY_STRINGIFY_EX
24301#undef JSON_HEDLEY_SUNPRO_VERSION
24302#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
24303#undef JSON_HEDLEY_TINYC_VERSION
24304#undef JSON_HEDLEY_TINYC_VERSION_CHECK
24305#undef JSON_HEDLEY_TI_ARMCL_VERSION
24306#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
24307#undef JSON_HEDLEY_TI_CL2000_VERSION
24308#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
24309#undef JSON_HEDLEY_TI_CL430_VERSION
24310#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
24311#undef JSON_HEDLEY_TI_CL6X_VERSION
24312#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
24313#undef JSON_HEDLEY_TI_CL7X_VERSION
24314#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
24315#undef JSON_HEDLEY_TI_CLPRU_VERSION
24316#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
24317#undef JSON_HEDLEY_TI_VERSION
24318#undef JSON_HEDLEY_TI_VERSION_CHECK
24319#undef JSON_HEDLEY_UNAVAILABLE
24320#undef JSON_HEDLEY_UNLIKELY
24321#undef JSON_HEDLEY_UNPREDICTABLE
24322#undef JSON_HEDLEY_UNREACHABLE
24323#undef JSON_HEDLEY_UNREACHABLE_RETURN
24324#undef JSON_HEDLEY_VERSION
24325#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
24326#undef JSON_HEDLEY_VERSION_DECODE_MINOR
24327#undef JSON_HEDLEY_VERSION_DECODE_REVISION
24328#undef JSON_HEDLEY_VERSION_ENCODE
24329#undef JSON_HEDLEY_WARNING
24330#undef JSON_HEDLEY_WARN_UNUSED_RESULT
24331#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
24332#undef JSON_HEDLEY_FALL_THROUGH
namespace for Niels Lohmann
Definition: json.hpp:19065
static JSON_HEDLEY_RETURNS_NON_NULL T * create(Args &&... args)
helper for exception-safe object creation
Definition: json.hpp:19347
reference operator+=(const typename object_t::value_type &val)
add an object to an object
Definition: json.hpp:22086
json_value(typename binary_t::container_type &&value)
constructor for rvalue binary arrays
Definition: json.hpp:19515
void destroy(value_t t)
Definition: json.hpp:19523
reference operator+=(basic_json &&val)
add an object to an array
Definition: json.hpp:22023
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
Definition: json.hpp:23460
size_type count(KeyType &&key) const
returns the number of occurrences of a key in a JSON object
Definition: json.hpp:21628
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array
Definition: json.hpp:19939
std::decay< ValueType >::type value(const KeyType &key, ValueType &&default_value) const
access specified object element with default value
Definition: json.hpp:21173
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
Definition: json.hpp:19215
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
Definition: json.hpp:19961
void set_parents()
Definition: json.hpp:19662
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
Definition: json.hpp:21652
void erase(const size_type idx)
remove element from a JSON array given an index
Definition: json.hpp:21528
void push_back(const basic_json &val)
add an object to an array
Definition: json.hpp:22031
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
Definition: json.hpp:19969
::nlohmann::detail::output_adapter_t< CharType > output_adapter_t
Definition: json.hpp:19119
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
Definition: json.hpp:23122
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
Definition: json.hpp:19989
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
Definition: json.hpp:20250
detail::parser_callback_t< basic_json > parser_callback_t
per-element parser callback type
Definition: json.hpp:19761
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
Definition: json.hpp:21405
json_value(const binary_t &value)
constructor for binary arrays (internal type)
Definition: json.hpp:19518
const_reference operator[](T *key) const
Definition: json.hpp:21120
number_float_t number_float
number (floating-point)
Definition: json.hpp:19409
static allocator_type get_allocator()
returns the allocator associated with the container
Definition: json.hpp:19207
json_value(boolean_t v) noexcept
constructor for booleans
Definition: json.hpp:19414
const_reference back() const
access the last element
Definition: json.hpp:21323
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
Definition: json.hpp:24009
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts copies of element into array
Definition: json.hpp:22222
boolean_t * get_impl_ptr(boolean_t *) noexcept
get a pointer to the value (boolean)
Definition: json.hpp:20408
NumberFloatType number_float_t
a type for a number (floating-point)
Definition: json.hpp:19330
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition: json.hpp:20512
void swap(object_t &other)
exchanges the values
Definition: json.hpp:22417
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
Definition: json.hpp:19139
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition: json.hpp:20501
constexpr const array_t * get_impl_ptr(const array_t *) const noexcept
get a pointer to the value (array)
Definition: json.hpp:20390
void swap(binary_t &other)
exchanges the values
Definition: json.hpp:22449
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
Definition: json.hpp:20754
reference operator[](typename object_t::key_type key)
access specified object element
Definition: json.hpp:21076
basic_json get_impl(detail::priority_tag< 3 >) const
get special-case overload
Definition: json.hpp:20652
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
Definition: json.hpp:19191
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) reference operator[](const
Definition: json.hpp:23511
iter_impl< basic_json > iterator
an iterator for a basic_json container
Definition: json.hpp:19194
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) ValueType value(const
access specified object element via JSON Pointer with default value
Definition: json.hpp:21275
ValueType get_impl(detail::priority_tag< 1 >) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >())))
get a value (explicit); special case
Definition: json.hpp:20604
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
a const reverse iterator for a basic_json container
Definition: json.hpp:19200
static std::vector< std::uint8_t > to_bjdata(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
Definition: json.hpp:23195
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition: json.hpp:22325
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
Definition: json.hpp:23505
std::ptrdiff_t difference_type
a type to represent differences between iterators
Definition: json.hpp:19181
size_type erase(KeyType &&key)
remove element from a JSON object given a key
Definition: json.hpp:21521
basic_json(const JsonRef &ref)
Definition: json.hpp:20099
json_value m_value
the value of the current element
Definition: json.hpp:23105
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
Definition: json.hpp:20741
object_t * get_impl_ptr(object_t *) noexcept
get a pointer to the value (object)
Definition: json.hpp:20372
::nlohmann::detail::json_reverse_iterator< Base > json_reverse_iterator
Definition: json.hpp:19116
bool contains(const typename object_t::key_type &key) const
check the existence of an element in a JSON object
Definition: json.hpp:21636
number_unsigned_t number_unsigned
number (unsigned integer)
Definition: json.hpp:19407
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements from initializer list into array
Definition: json.hpp:22273
string_t * get_impl_ptr(string_t *) noexcept
get a pointer to the value (string)
Definition: json.hpp:20396
constexpr bool is_string() const noexcept
return whether value is a string
Definition: json.hpp:20327
json_value(const object_t &value)
constructor for objects
Definition: json.hpp:19500
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
Definition: json.hpp:22144
::nlohmann::detail::binary_reader< basic_json, InputType > binary_reader
Definition: json.hpp:19122
const_iterator find(KeyType &&key) const
find an element in a JSON object
Definition: json.hpp:21604
ReferenceType get_ref() const
get a reference value (implicit)
Definition: json.hpp:20801
constexpr const object_t * get_impl_ptr(const object_t *) const noexcept
get a pointer to the value (object)
Definition: json.hpp:20378
iterator insert(const_iterator pos, const basic_json &val)
inserts element into array
Definition: json.hpp:22195
const binary_t & get_binary() const
get a binary value
Definition: json.hpp:20872
::nlohmann::detail::iteration_proxy< Iterator > iteration_proxy
Definition: json.hpp:19115
AllocatorType< basic_json > allocator_type
the allocator type
Definition: json.hpp:19186
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
create a CBOR serialization of a given JSON value
Definition: json.hpp:23138
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
Definition: json.hpp:23145
void push_back(const typename object_t::value_type &val)
add an object to an object
Definition: json.hpp:22063
std::decay< ValueType >::type value(KeyType &&key, ValueType &&default_value) const
access specified object element with default value
Definition: json.hpp:21222
string_t * string
string (stored with pointer to save storage)
Definition: json.hpp:19399
bool contains(KeyType &&key) const
check the existence of an element in a JSON object
Definition: json.hpp:21645
void swap(reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition: json.hpp:22372
basic_json patch(const basic_json &json_patch) const
applies a JSON patch to a copy of the current object
Definition: json.hpp:23857
number_integer_t * get_impl_ptr(number_integer_t *) noexcept
get a pointer to the value (integer number)
Definition: json.hpp:20420
reference operator[](KeyType &&key)
access specified object element
Definition: json.hpp:21129
array_t * get_impl_ptr(array_t *) noexcept
get a pointer to the value (array)
Definition: json.hpp:20384
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
Definition: json.hpp:23445
boolean_t get_impl(boolean_t *) const
get a boolean (explicit)
Definition: json.hpp:20361
iterator insert(const_iterator pos, basic_json &&val)
inserts element into array
Definition: json.hpp:22215
JSONSerializer< T, SFINAE > json_serializer
Definition: json.hpp:19133
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:20895
const_reference operator[](size_type idx) const
access specified array element
Definition: json.hpp:21063
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
create a BSON serialization of a given JSON value
Definition: json.hpp:23238
void swap(typename binary_t::container_type &other)
exchanges the values
Definition: json.hpp:22465
static ::nlohmann::detail::parser< basic_json, InputAdapterType > parser(InputAdapterType adapter, detail::parser_callback_t< basic_json >cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
Definition: json.hpp:19097
constexpr const number_integer_t * get_impl_ptr(const number_integer_t *) const noexcept
get a pointer to the value (integer number)
Definition: json.hpp:20426
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition: json.hpp:23360
iterator insert_iterator(const_iterator pos, Args &&... args)
Definition: json.hpp:22176
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
Definition: json.hpp:19950
string_t value(const typename object_t::key_type &key, const char *default_value) const
access specified object element with default value
Definition: json.hpp:21194
constexpr bool is_null() const noexcept
return whether value is null
Definition: json.hpp:20271
number_integer_t number_integer
number (integer)
Definition: json.hpp:19405
std::decay< ValueType >::type value(const char *key, ValueType &&default_value) const
Definition: json.hpp:21205
binary_t * binary
binary (stored with pointer to save storage)
Definition: json.hpp:19401
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) reference at(const
Definition: json.hpp:23539
static std::vector< std::uint8_t > to_ubjson(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition: json.hpp:23168
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
Definition: json.hpp:23069
ObjectType< StringType, basic_json, default_object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > > > object_t
a type for an object
Definition: json.hpp:19306
detail::actual_object_comparator_t< basic_json > object_comparator_t
object key comparator type
Definition: json.hpp:19338
void insert(const_iterator first, const_iterator last)
inserts range of elements into object
Definition: json.hpp:22293
IteratorType erase(IteratorType pos)
remove element given an iterator
Definition: json.hpp:21335
reference emplace_back(Args &&... args)
add an object to an array
Definition: json.hpp:22119
ReferenceType get_ref()
get a reference value (implicit)
Definition: json.hpp:20790
::nlohmann::json_pointer< StringType > json_pointer
JSON Pointer, see nlohmann::json_pointer.
Definition: json.hpp:19131
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
Definition: json.hpp:19310
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
create a MessagePack serialization of a given JSON value
Definition: json.hpp:23161
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition: json.hpp:23321
constexpr bool is_primitive() const noexcept
return whether type is primitive
Definition: json.hpp:20257
StringType string_t
a type for a string
Definition: json.hpp:19314
constexpr bool is_boolean() const noexcept
return whether value is a boolean
Definition: json.hpp:20278
json_value(array_t &&value)
constructor for rvalue arrays
Definition: json.hpp:19509
static void to_ubjson(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition: json.hpp:23187
json_value()=default
default constructor (for null values)
iterator find(KeyType &&key)
find an element in a JSON object
Definition: json.hpp:21588
boolean_t boolean
boolean
Definition: json.hpp:19403
json_value(value_t t)
constructor for empty values of a given type
Definition: json.hpp:19422
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition: json.hpp:23247
const_reference front() const
access the first element
Definition: json.hpp:21307
static std::vector< std::uint8_t > to_bson(const basic_json &j)
create a BSON serialization of a given JSON value
Definition: json.hpp:23222
array_t * array
array (stored with pointer to save storage)
Definition: json.hpp:19397
json_value(const string_t &value)
constructor for strings
Definition: json.hpp:19494
std::size_t size_type
a type to represent container sizes
Definition: json.hpp:19183
constexpr bool is_array() const noexcept
return whether value is an array
Definition: json.hpp:20320
NumberIntegerType number_integer_t
a type for a number (integer)
Definition: json.hpp:19322
basic_json & operator=(basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
copy assignment
Definition: json.hpp:20188
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
Definition: json.hpp:19917
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
Definition: json.hpp:21510
const_iterator find(const typename object_t::key_type &key) const
find an element in a JSON object
Definition: json.hpp:21572
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
Definition: json.hpp:21254
iterator find(const typename object_t::key_type &key)
find an element in a JSON object
Definition: json.hpp:21558
iter_impl< const basic_json > const_iterator
a const iterator for a basic_json container
Definition: json.hpp:19196
constexpr const binary_t * get_impl_ptr(const binary_t *) const noexcept
get a pointer to the value (binary)
Definition: json.hpp:20462
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a CBOR serialization of a given JSON value
Definition: json.hpp:23131
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition: json.hpp:23263
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
Definition: json.hpp:19808
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
Definition: json.hpp:23430
::nlohmann::detail::binary_writer< basic_json, CharType > binary_writer
Definition: json.hpp:19123
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition: json.hpp:23306
const_reference at(size_type idx) const
access specified array element with bounds checking
Definition: json.hpp:20918
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
Definition: json.hpp:19928
basic_json(CompatibleType &&val) noexcept(noexcept(//NOLINT(bugprone-forwarding-reference-overload, bugprone-exception-escape) JSONSerializer< U >::to_json(std::declval< basic_json_t & >(), std::forward< CompatibleType >(val))))
create a JSON value from compatible types
Definition: json.hpp:19794
static void to_bjdata(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
Definition: json.hpp:23206
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
Definition: json.hpp:23519
JSON_HEDLEY_DEPRECATED_FOR(3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) const _reference operator[](const
access specified element via JSON Pointer
Definition: json.hpp:23525
static void to_bjdata(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
Definition: json.hpp:23214
ValueType & get_to(ValueType &v) const
Definition: json.hpp:20767
::nlohmann::detail::internal_iterator< BasicJsonType > internal_iterator
Definition: json.hpp:19111
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition: json.hpp:22318
constexpr const boolean_t * get_impl_ptr(const boolean_t *) const noexcept
get a pointer to the value (boolean)
Definition: json.hpp:20414
constexpr bool is_binary() const noexcept
return whether value is a binary array
Definition: json.hpp:20334
basic_json(basic_json &&other) noexcept
move constructor
Definition: json.hpp:20171
reference operator[](size_type idx)
access specified array element
Definition: json.hpp:21017
binary_t & get_binary()
get a binary value
Definition: json.hpp:20860
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
Definition: json.hpp:20299
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
Definition: json.hpp:20306
void swap(string_t &other)
exchanges the values
Definition: json.hpp:22433
nlohmann::byte_container_with_subtype< BinaryType > binary_t
a type for a packed binary type
Definition: json.hpp:19334
NLOHMANN_BASIC_JSON_TPL basic_json_t
workaround type for MSVC
Definition: json.hpp:19090
auto get() const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))
get a (pointer) value (explicit)
Definition: json.hpp:20700
constexpr const number_float_t * get_impl_ptr(const number_float_t *) const noexcept
get a pointer to the value (floating-point number)
Definition: json.hpp:20450
json_value(const array_t &value)
constructor for arrays
Definition: json.hpp:19506
json_value(binary_t &&value)
constructor for rvalue binary arrays (internal type)
Definition: json.hpp:19521
constexpr bool is_number() const noexcept
return whether value is a number
Definition: json.hpp:20285
::nlohmann::detail::iter_impl< BasicJsonType > iter_impl
Definition: json.hpp:19113
json_value(number_integer_t v) noexcept
constructor for numbers (integer)
Definition: json.hpp:19416
reference operator[](T *key)
Definition: json.hpp:21114
constexpr bool is_discarded() const noexcept
return whether value is discarded
Definition: json.hpp:20341
json_value(object_t &&value)
constructor for rvalue objects
Definition: json.hpp:19503
static ReferenceType get_ref_impl(ThisType &obj)
helper function to implement get_ref()
Definition: json.hpp:20479
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
Definition: json.hpp:19189
size_type count(const typename object_t::key_type &key) const
returns the number of occurrences of a key in a JSON object
Definition: json.hpp:21618
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
Definition: json.hpp:20228
basic_json(const basic_json &other)
copy constructor
Definition: json.hpp:20103
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
a reverse iterator for a basic_json container
Definition: json.hpp:19198
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
Definition: json.hpp:20778
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
Definition: json.hpp:19782
constexpr const string_t * get_impl_ptr(const string_t *) const noexcept
get a pointer to the value (string)
Definition: json.hpp:20402
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
Definition: json.hpp:23547
iterator set_parents(iterator it, typename iterator::difference_type count_set_parents)
Definition: json.hpp:19699
~basic_json() noexcept
destructor
Definition: json.hpp:20209
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
Definition: json.hpp:20292
json_value(number_float_t v) noexcept
constructor for numbers (floating-point)
Definition: json.hpp:19420
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition: json.hpp:23375
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
Definition: json.hpp:19976
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a BSON serialization of a given JSON value
Definition: json.hpp:23231
string_t value(KeyType &&key, const char *default_value) const
access specified object element with default value
Definition: json.hpp:21245
ValueType get_impl(detail::priority_tag< 0 >) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), std::declval< ValueType & >())))
get a value (explicit)
Definition: json.hpp:20562
static void to_ubjson(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition: json.hpp:23179
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a MessagePack serialization of a given JSON value
Definition: json.hpp:23154
binary_t * get_impl_ptr(binary_t *) noexcept
get a pointer to the value (binary)
Definition: json.hpp:20456
void push_back(initializer_list_t init)
add an object to an object
Definition: json.hpp:22094
reference back()
access the last element
Definition: json.hpp:21314
constexpr bool is_structured() const noexcept
return whether type is structured
Definition: json.hpp:20264
void assert_invariant(bool check_parents=true) const noexcept
checks the class invariants
Definition: json.hpp:19641
reference set_parent(reference j, std::size_t old_capacity=static_cast< std::size_t >(-1))
Definition: json.hpp:19712
reference operator+=(initializer_list_t init)
add an object to an object
Definition: json.hpp:22110
json_value(const typename binary_t::container_type &value)
constructor for binary arrays
Definition: json.hpp:19512
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
Definition: json.hpp:23054
json_value(number_unsigned_t v) noexcept
constructor for numbers (unsigned)
Definition: json.hpp:19418
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
Definition: json.hpp:19326
basic_json(initializer_list_t init, bool type_deduction=true, value_t manual_type=value_t::array)
create a container (array or object) from an initializer list
Definition: json.hpp:19861
string_t value(const char *key, const char *default_value) const
Definition: json.hpp:21210
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
Definition: json.hpp:20941
friend void swap(reference left, reference right) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition: json.hpp:22389
basic_json(const value_t v)
create an empty value with a given type
Definition: json.hpp:19774
const_reference at(KeyType &&key) const
access specified object element with bounds checking
Definition: json.hpp:20999
void swap(array_t &other)
exchanges the values
Definition: json.hpp:22401
std::less< StringType > default_object_comparator_t
default object key comparator type The actual object key comparator type (object_comparator_t) may be...
Definition: json.hpp:19297
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts range of elements into array
Definition: json.hpp:22242
BooleanType boolean_t
a type for a boolean
Definition: json.hpp:19318
number_unsigned_t * get_impl_ptr(number_unsigned_t *) noexcept
get a pointer to the value (unsigned number)
Definition: json.hpp:20432
constexpr const number_unsigned_t * get_impl_ptr(const number_unsigned_t *) const noexcept
get a pointer to the value (unsigned number)
Definition: json.hpp:20438
json_value(string_t &&value)
constructor for rvalue strings
Definition: json.hpp:19497
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
Definition: json.hpp:21098
size_type erase_internal(KeyType &&key)
Definition: json.hpp:21476
constexpr bool is_object() const noexcept
return whether value is an object
Definition: json.hpp:20313
constexpr auto get_impl(detail::priority_tag< 4 >) const noexcept -> decltype(std::declval< const basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
Definition: json.hpp:20665
BasicJsonType get_impl(detail::priority_tag< 2 >) const
get special-case overload
Definition: json.hpp:20629
const_reference operator[](KeyType &&key) const
access specified object element
Definition: json.hpp:21153
reference operator+=(const basic_json &val)
add an object to an array
Definition: json.hpp:22055
number_float_t * get_impl_ptr(number_float_t *) noexcept
get a pointer to the value (floating-point number)
Definition: json.hpp:20444
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
Definition: json.hpp:20979
reference at(KeyType &&key)
access specified object element with bounds checking
Definition: json.hpp:20961
::nlohmann::detail::primitive_iterator_t primitive_iterator_t
Definition: json.hpp:19109
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff(const basic_json &source, const basic_json &target, const std::string &path="")
creates a diff as a JSON patch
Definition: json.hpp:23867
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
Definition: json.hpp:23415
an internal type for a backed binary type
Definition: json.hpp:5736
bool operator!=(const byte_container_with_subtype &rhs) const
Definition: json.hpp:5776
byte_container_with_subtype() noexcept(noexcept(container_type()))
Definition: json.hpp:5742
std::uint64_t subtype_type
Definition: json.hpp:5739
bool operator==(const byte_container_with_subtype &rhs) const
Definition: json.hpp:5770
BinaryType container_type
Definition: json.hpp:5738
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
Definition: json.hpp:5764
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
Definition: json.hpp:5752
constexpr subtype_type subtype() const noexcept
return the binary subtype
Definition: json.hpp:5791
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
Definition: json.hpp:5757
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
Definition: json.hpp:5798
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
Definition: json.hpp:5747
subtype_type m_subtype
Definition: json.hpp:5812
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
Definition: json.hpp:5783
bool m_has_subtype
Definition: json.hpp:5813
void clear_subtype() noexcept
clears the binary subtype
Definition: json.hpp:5805
deserialization of CBOR, MessagePack, and UBJSON values
Definition: json.hpp:9059
bool get_string(const input_format_t format, const NumberType len, string_t &result)
create a string by reading characters from the input
Definition: json.hpp:11823
bool get_ubjson_size_type(std::pair< std::size_t, char_int_type > &result, bool inside_ndarray=false)
determine the type and size for a container
Definition: json.hpp:11223
binary_reader(const binary_reader &)=delete
bool parse_bson_array()
Reads an array from the BSON input and passes it to the SAX-parser.
Definition: json.hpp:9381
typename BasicJsonType::string_t string_t
Definition: json.hpp:9063
typename std::char_traits< char_type >::int_type char_int_type
Definition: json.hpp:9067
bool parse_bson_element_list(const bool is_array)
Read a BSON element list (as specified in the BSON-spec)
Definition: json.hpp:9343
typename InputAdapterType::char_type char_type
Definition: json.hpp:9066
bool parse_msgpack_internal()
Definition: json.hpp:10187
std::string get_token_string() const
Definition: json.hpp:11893
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:9061
bool get_msgpack_string(string_t &result)
reads a MessagePack string
Definition: json.hpp:10568
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
Definition: json.hpp:11906
InputAdapterType ia
input adapter
Definition: json.hpp:11944
bool get_ubjson_high_precision_number()
Definition: json.hpp:11665
bool get_binary(const input_format_t format, const NumberType len, binary_t &result)
create a byte array by reading bytes from the input
Definition: json.hpp:11856
binary_reader(binary_reader &&)=default
char_int_type get_ignore_noop()
Definition: json.hpp:11753
bool get_ubjson_value(const char_int_type prefix)
Definition: json.hpp:11291
bool get_ubjson_ndarray_size(std::vector< size_t > &dim)
Definition: json.hpp:10935
bool parse_bson_element_internal(const char_int_type element_type, const std::size_t element_type_parse_position)
Read a BSON document element of the given element_type.
Definition: json.hpp:9263
bool get_msgpack_object(const std::size_t len)
Definition: json.hpp:10784
binary_reader(InputAdapterType &&adapter, const input_format_t format=input_format_t::json) noexcept
create a binary reader
Definition: json.hpp:9075
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:9064
bool parse_bson_internal()
Reads in a BSON-object and passes it to the SAX-parser.
Definition: json.hpp:9159
binary_reader & operator=(const binary_reader &)=delete
bool get_cbor_object(const std::size_t len, const cbor_tag_handler_t tag_handler)
Definition: json.hpp:10131
bool get_cbor_binary(binary_t &result)
reads a CBOR byte array
Definition: json.hpp:9998
bool get_number(const input_format_t format, NumberType &result)
Definition: json.hpp:11780
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:9060
bool get_ubjson_array()
Definition: json.hpp:11474
bool get_bson_cstr(string_t &result)
Parses a C-style string from the BSON input.
Definition: json.hpp:9184
bool sax_parse(const input_format_t format, json_sax_t *sax_, const bool strict=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
Definition: json.hpp:9096
bool get_cbor_array(const std::size_t len, const cbor_tag_handler_t tag_handler)
Definition: json.hpp:10093
bool get_msgpack_array(const std::size_t len)
Definition: json.hpp:10762
char_int_type get()
get next character from the input
Definition: json.hpp:11744
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:9062
bool get_msgpack_binary(binary_t &result)
reads a MessagePack byte array
Definition: json.hpp:10651
bool parse_ubjson_internal(const bool get_char=true)
Definition: json.hpp:10821
SAX json_sax_t
Definition: json.hpp:9065
bool get_ubjson_size_value(std::size_t &result, bool &is_ndarray, char_int_type prefix=0)
Definition: json.hpp:11000
bool parse_cbor_internal(const bool get_char, const cbor_tag_handler_t tag_handler)
Definition: json.hpp:9411
bool get_ubjson_object()
Definition: json.hpp:11582
bool get_bson_string(const NumberType len, string_t &result)
Parses a zero-terminated string of length len from the BSON input.
Definition: json.hpp:9214
bool get_ubjson_string(string_t &result, const bool get_char=true)
reads a UBJSON string
Definition: json.hpp:10840
bool get_cbor_string(string_t &result)
reads a CBOR string
Definition: json.hpp:9902
bool get_bson_binary(const NumberType len, binary_t &result)
Parses a byte array input of length len from the BSON input.
Definition: json.hpp:9236
binary_reader & operator=(binary_reader &&)=default
serialization to CBOR and MessagePack values
Definition: json.hpp:14746
void write_bson_binary(const string_t &name, const binary_t &value)
Writes a BSON element with key name and binary value value.
Definition: json.hpp:15855
void write_bson_boolean(const string_t &name, const bool value)
Writes a BSON element with key name and boolean value value.
Definition: json.hpp:15693
void write_bson(const BasicJsonType &j)
Definition: json.hpp:14766
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:14748
void write_bson_integer(const string_t &name, const std::int64_t value)
Writes a BSON element with key name and integer value.
Definition: json.hpp:15753
typename BasicJsonType::string_t string_t
Definition: json.hpp:14747
static constexpr CharType to_char_type(std::uint8_t x) noexcept
Definition: json.hpp:16501
static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept
Definition: json.hpp:15771
void write_bson_array(const string_t &name, const typename BasicJsonType::array_t &value)
Writes a BSON element with key name and array value.
Definition: json.hpp:15836
bool write_bjdata_ndarray(const typename BasicJsonType::object_t &value, const bool use_count, const bool use_type)
Definition: json.hpp:16324
static CharType to_char_type(std::uint8_t x) noexcept
Definition: json.hpp:16508
static constexpr CharType get_cbor_float_prefix(double)
Definition: json.hpp:16001
void write_bson_string(const string_t &name, const string_t &value)
Writes a BSON element with key name and string value value.
Definition: json.hpp:15721
binary_writer(output_adapter_t< CharType > adapter)
create a binary writer
Definition: json.hpp:14757
static constexpr CharType get_ubjson_float_prefix(double)
Definition: json.hpp:16316
void write_number_with_ubjson_prefix(const NumberType n, const bool add_prefix, const bool use_bjdata)
Definition: json.hpp:16027
static constexpr CharType get_msgpack_float_prefix(double)
Definition: json.hpp:16015
void write_bson_element(const string_t &name, const BasicJsonType &j)
Serializes the JSON value j to BSON and associates it with the key name.
Definition: json.hpp:15918
static constexpr CharType to_char_type(InputCharType x) noexcept
Definition: json.hpp:16530
void write_bson_object(const typename BasicJsonType::object_t &value)
Definition: json.hpp:15980
void write_ubjson(const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true, const bool use_bjdata=false)
Definition: json.hpp:15445
void write_bson_double(const string_t &name, const double value)
Writes a BSON element with key name and double value value.
Definition: json.hpp:15703
static std::size_t calc_bson_string_size(const string_t &value)
Definition: json.hpp:15713
void write_number(const NumberType n, const bool OutputIsLittleEndian=false)
Definition: json.hpp:16451
static std::size_t calc_bson_entry_header_size(const string_t &name, const BasicJsonType &j)
Definition: json.hpp:15666
void write_bson_null(const string_t &name)
Writes a BSON element with key name and null value.
Definition: json.hpp:15735
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:14749
CharType ubjson_prefix(const BasicJsonType &j, const bool use_bjdata) const noexcept
determine the type prefix of container values
Definition: json.hpp:16210
void write_bson_unsigned(const string_t &name, const BasicJsonType &j)
Writes a BSON element with key name and unsigned value.
Definition: json.hpp:15781
static constexpr CharType get_ubjson_float_prefix(float)
Definition: json.hpp:16311
static std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t &value)
Definition: json.hpp:15828
static std::size_t calc_bson_element_size(const string_t &name, const BasicJsonType &j)
Calculates the size necessary to serialize the JSON value j with its name.
Definition: json.hpp:15870
void write_msgpack(const BasicJsonType &j)
Definition: json.hpp:15119
static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t &value)
Calculates the size of the BSON serialization of the given JSON-object j.
Definition: json.hpp:15965
void write_compact_float(const number_float_t n, detail::input_format_t format)
Definition: json.hpp:16467
void write_cbor(const BasicJsonType &j)
Definition: json.hpp:14795
static constexpr CharType get_cbor_float_prefix(float)
Definition: json.hpp:15996
void write_bson_entry_header(const string_t &name, const std::uint8_t element_type)
Writes the given element_type and name to the output adapter.
Definition: json.hpp:15681
void write_bson_object_entry(const string_t &name, const typename BasicJsonType::object_t &value)
Writes a BSON element with key name and object value.
Definition: json.hpp:15803
static constexpr CharType get_msgpack_float_prefix(float)
Definition: json.hpp:16010
static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t &value)
Definition: json.hpp:15813
static std::size_t calc_bson_integer_size(const std::int64_t value)
Definition: json.hpp:15743
general exception of the basic_json class
Definition: json.hpp:4223
const int id
the id of the exception
Definition: json.hpp:4232
static std::string diagnostics(std::nullptr_t)
Definition: json.hpp:4243
std::runtime_error m
an exception object as storage for error messages
Definition: json.hpp:4315
static std::string name(const std::string &ename, int id_)
Definition: json.hpp:4238
const char * what() const noexcept override
returns the explanatory string
Definition: json.hpp:4226
static std::string diagnostics(const BasicJsonType *leaf_element)
Definition: json.hpp:4249
exception indicating errors with iterators
Definition: json.hpp:4374
static invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4377
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
Definition: json.hpp:12713
iter_impl operator+(difference_type i) const
add to iterator
Definition: json.hpp:13287
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
Definition: json.hpp:12850
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
Definition: json.hpp:13232
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
Definition: json.hpp:12840
bool operator<(const iter_impl &other) const
comparison: smaller
Definition: json.hpp:13179
bool operator<=(const iter_impl &other) const
comparison: less than or equal
Definition: json.hpp:13214
iter_impl & operator-=(difference_type i)
subtract from iterator
Definition: json.hpp:13278
iter_impl & operator--()
pre-decrement (–it)
Definition: json.hpp:13093
const object_t::key_type & key() const
return the key of an object iterator
Definition: json.hpp:13387
bool operator==(const IterImpl &other) const
comparison: equal
Definition: json.hpp:13134
iter_impl operator++(int) &
post-increment (it++)
Definition: json.hpp:13031
iter_impl & operator+=(difference_type i)
add to iterator
Definition: json.hpp:13241
reference operator[](difference_type n) const
access to successor
Definition: json.hpp:13349
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
Definition: json.hpp:12743
pointer operator->() const
dereference the iterator
Definition: json.hpp:12989
friend other_iter_impl
allow basic_json to access private members
Definition: json.hpp:12717
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:13412
difference_type operator-(const iter_impl &other) const
return difference
Definition: json.hpp:13320
iter_impl(iter_impl &&) noexcept=default
std::bidirectional_iterator_tag iterator_category
Definition: json.hpp:12738
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
Definition: json.hpp:13298
reference value() const
return the value of an iterator
Definition: json.hpp:13403
bool operator>(const iter_impl &other) const
comparison: greater than
Definition: json.hpp:13223
typename BasicJsonType::array_t array_t
Definition: json.hpp:12723
typename BasicJsonType::object_t object_t
Definition: json.hpp:12722
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type pointer
defines a pointer to the type iterated over (value_type)
Definition: json.hpp:12747
iter_impl & operator++()
pre-increment (++it)
Definition: json.hpp:13042
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
Definition: json.hpp:12741
reference operator*() const
return a reference to the value pointed to by the iterator
Definition: json.hpp:12945
iter_impl operator-(difference_type i) const
subtract from iterator
Definition: json.hpp:13309
friend BasicJsonType
Definition: json.hpp:12718
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
Definition: json.hpp:12825
bool operator!=(const IterImpl &other) const
comparison: not equal
Definition: json.hpp:13170
iter_impl operator--(int) &
post-decrement (it–)
Definition: json.hpp:13082
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type reference
defines a reference to the type iterated over (value_type)
Definition: json.hpp:12752
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
Definition: json.hpp:12815
void set_end() noexcept
set the iterator past the last value
Definition: json.hpp:12906
Definition: json.hpp:5037
iteration_proxy_value operator++(int) &
Definition: json.hpp:5093
iteration_proxy_value(iteration_proxy_value const &)=default
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
Definition: json.hpp:5102
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
Definition: json.hpp:5108
std::ptrdiff_t difference_type
Definition: json.hpp:5039
string_type empty_str
an empty string (to return a reference for primitive values)
Definition: json.hpp:5056
iteration_proxy_value(IteratorType it, std::size_t array_index_=0) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_default_constructible< string_type >::value)
Definition: json.hpp:5060
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
Definition: json.hpp:5085
iteration_proxy_value()=default
std::size_t array_index_last
last stringified array index
Definition: json.hpp:5052
std::size_t array_index
an index for arrays (used to create key names)
Definition: json.hpp:5050
iteration_proxy_value(iteration_proxy_value &&) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_move_constructible< string_type >::value)=default
IteratorType::reference value() const
return value of the iterator
Definition: json.hpp:5150
const string_type & key() const
return key of the iterator
Definition: json.hpp:5114
iteration_proxy_value & operator=(iteration_proxy_value const &)=default
std::input_iterator_tag iterator_category
Definition: json.hpp:5043
string_type array_index_str
a string representation of the array index
Definition: json.hpp:5054
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
Definition: json.hpp:5044
IteratorType anchor
the iterator
Definition: json.hpp:5048
proxy class for the items() function
Definition: json.hpp:5158
IteratorType::pointer container
the container to iterate
Definition: json.hpp:5161
iteration_proxy_value< IteratorType > end() const noexcept
return iterator end (needed for range-based for)
Definition: json.hpp:5183
iteration_proxy(iteration_proxy const &)=default
iteration_proxy()=default
iteration_proxy(iteration_proxy &&) noexcept=default
iteration_proxy_value< IteratorType > begin() const noexcept
return iterator begin (needed for range-based for)
Definition: json.hpp:5177
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
Definition: json.hpp:5167
iteration_proxy & operator=(iteration_proxy const &)=default
Definition: json.hpp:14487
json_ref(json_ref &&) noexcept=default
json_ref(const value_type &value)
Definition: json.hpp:14495
json_ref(value_type &&value)
Definition: json.hpp:14491
value_type const & operator*() const
Definition: json.hpp:14526
value_type const * operator->() const
Definition: json.hpp:14531
json_ref(std::initializer_list< json_ref > init)
Definition: json.hpp:14499
json_ref(Args &&... args)
Definition: json.hpp:14506
value_type moved_or_copied() const
Definition: json.hpp:14517
BasicJsonType value_type
Definition: json.hpp:14489
a template for a reverse iterator class
Definition: json.hpp:13466
json_reverse_iterator operator++(int) &
post-increment (it++)
Definition: json.hpp:13482
json_reverse_iterator operator--(int) &
post-decrement (it–)
Definition: json.hpp:13494
json_reverse_iterator & operator++()
pre-increment (++it)
Definition: json.hpp:13488
std::ptrdiff_t difference_type
Definition: json.hpp:13468
json_reverse_iterator & operator+=(difference_type i)
add to iterator
Definition: json.hpp:13506
reference operator[](difference_type n) const
access to successor
Definition: json.hpp:13530
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
Definition: json.hpp:13536
difference_type operator-(const json_reverse_iterator &other) const
return difference
Definition: json.hpp:13524
typename Base::reference reference
the reference type for the pointed-to element
Definition: json.hpp:13472
reference value() const
return the value of an iterator
Definition: json.hpp:13543
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
Definition: json.hpp:13479
json_reverse_iterator & operator--()
pre-decrement (–it)
Definition: json.hpp:13500
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
Definition: json.hpp:13470
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
Definition: json.hpp:13518
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
Definition: json.hpp:13475
json_reverse_iterator operator+(difference_type i) const
add to iterator
Definition: json.hpp:13512
Definition: json.hpp:7138
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:7141
bool end_object()
Definition: json.hpp:7191
bool start_object(std::size_t=static_cast< std::size_t >(-1))
Definition: json.hpp:7181
bool binary(binary_t &)
Definition: json.hpp:7176
bool number_integer(number_integer_t)
Definition: json.hpp:7156
bool start_array(std::size_t=static_cast< std::size_t >(-1))
Definition: json.hpp:7196
bool boolean(bool)
Definition: json.hpp:7151
bool null()
Definition: json.hpp:7146
bool end_array()
Definition: json.hpp:7201
bool number_unsigned(number_unsigned_t)
Definition: json.hpp:7161
bool string(string_t &)
Definition: json.hpp:7171
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:7144
bool number_float(number_float_t, const string_t &)
Definition: json.hpp:7166
bool parse_error(std::size_t, const std::string &, const detail::exception &)
Definition: json.hpp:7206
bool key(string_t &)
Definition: json.hpp:7186
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:7140
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:7142
typename BasicJsonType::string_t string_t
Definition: json.hpp:7143
Definition: json.hpp:6831
bool boolean(bool val)
Definition: json.hpp:6862
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition: json.hpp:7019
BasicJsonType & root
the parsed JSON value
Definition: json.hpp:7117
typename BasicJsonType::string_t string_t
Definition: json.hpp:6836
bool number_float(number_float_t val, const string_t &)
Definition: json.hpp:6880
constexpr bool is_errored() const
Definition: json.hpp:7031
bool string(string_t &val)
Definition: json.hpp:6886
json_sax_dom_callback_parser & operator=(const json_sax_dom_callback_parser &)=delete
json_sax_dom_callback_parser(const json_sax_dom_callback_parser &)=delete
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:6834
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:6837
bool start_object(std::size_t len)
Definition: json.hpp:6898
bool start_array(std::size_t len)
Definition: json.hpp:6969
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:6833
bool end_array()
Definition: json.hpp:6986
json_sax_dom_callback_parser(json_sax_dom_callback_parser &&)=default
bool key(string_t &val)
Definition: json.hpp:6916
bool end_object()
Definition: json.hpp:6933
std::pair< bool, BasicJsonType * > handle_value(Value &&v, const bool skip_callback=false)
Definition: json.hpp:7053
~json_sax_dom_callback_parser()=default
typename BasicJsonType::parse_event_t parse_event_t
Definition: json.hpp:6839
typename BasicJsonType::parser_callback_t parser_callback_t
Definition: json.hpp:6838
bool null()
Definition: json.hpp:6856
bool number_unsigned(number_unsigned_t val)
Definition: json.hpp:6874
json_sax_dom_callback_parser & operator=(json_sax_dom_callback_parser &&)=default
json_sax_dom_callback_parser(BasicJsonType &r, const parser_callback_t cb, const bool allow_exceptions_=true)
Definition: json.hpp:6841
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:6835
bool number_integer(number_integer_t val)
Definition: json.hpp:6868
bool binary(binary_t &val)
Definition: json.hpp:6892
SAX implementation to create a JSON value from SAX events.
Definition: json.hpp:6648
json_sax_dom_parser(const json_sax_dom_parser &)=delete
json_sax_dom_parser & operator=(json_sax_dom_parser &&)=default
bool string(string_t &val)
Definition: json.hpp:6702
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true)
Definition: json.hpp:6661
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition: json.hpp:6769
bool null()
Definition: json.hpp:6672
~json_sax_dom_parser()=default
typename BasicJsonType::string_t string_t
Definition: json.hpp:6653
bool start_object(std::size_t len)
Definition: json.hpp:6714
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:6651
bool number_unsigned(number_unsigned_t val)
Definition: json.hpp:6690
bool number_integer(number_integer_t val)
Definition: json.hpp:6684
JSON_HEDLEY_RETURNS_NON_NULL BasicJsonType * handle_value(Value &&v)
Definition: json.hpp:6795
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:6650
json_sax_dom_parser & operator=(const json_sax_dom_parser &)=delete
bool binary(binary_t &val)
Definition: json.hpp:6708
json_sax_dom_parser(json_sax_dom_parser &&)=default
BasicJsonType & root
the parsed JSON value
Definition: json.hpp:6818
bool boolean(bool val)
Definition: json.hpp:6678
bool end_array()
Definition: json.hpp:6758
bool number_float(number_float_t val, const string_t &)
Definition: json.hpp:6696
bool end_object()
Definition: json.hpp:6736
constexpr bool is_errored() const
Definition: json.hpp:6781
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:6654
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:6652
bool start_array(std::size_t len)
Definition: json.hpp:6746
bool key(string_t &val)
Definition: json.hpp:6726
Definition: json.hpp:7253
JSON_HEDLEY_RETURNS_NON_NULL static JSON_HEDLEY_CONST const char * token_type_name(const token_type t) noexcept
return name of values of type token_type (only used for errors)
Definition: json.hpp:7280
token_type
token types for the parser
Definition: json.hpp:7257
lexical analysis
Definition: json.hpp:7330
void reset() noexcept
reset token_buffer; current character is beginning of token
Definition: json.hpp:8538
bool skip_bom()
skip the UTF-8 byte order mark
Definition: json.hpp:8704
int get_codepoint()
get codepoint from 4 hex characters following \u
Definition: json.hpp:7387
token_type scan_string()
scan a string literal
Definition: json.hpp:7472
void skip_whitespace()
Definition: json.hpp:8718
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
Definition: json.hpp:7341
JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message() const noexcept
return syntax error message
Definition: json.hpp:8691
std::string get_token_string() const
Definition: json.hpp:8666
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:7333
constexpr number_integer_t get_number_integer() const noexcept
return integer value
Definition: json.hpp:8630
typename BasicJsonType::string_t string_t
Definition: json.hpp:7334
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:7332
bool next_byte_in_range(std::initializer_list< char_int_type > ranges)
check if the next byte(s) are inside a given range
Definition: json.hpp:7435
char_int_type get()
Definition: json.hpp:8555
constexpr position_t get_position() const noexcept
return position of last read token
Definition: json.hpp:8658
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:7331
token_type scan()
Definition: json.hpp:8727
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
Definition: json.hpp:8636
bool scan_comment()
scan a comment
Definition: json.hpp:8062
typename lexer_base< BasicJsonType >::token_type token_type
Definition: json.hpp:7339
lexer & operator=(lexer &&)=default
lexer(const lexer &)=delete
typename InputAdapterType::char_type char_type
Definition: json.hpp:7335
InputAdapterType ia
input adapter
Definition: json.hpp:8817
lexer & operator=(lexer &)=delete
token_type scan_number()
scan a number literal
Definition: json.hpp:8187
typename std::char_traits< char_type >::int_type char_int_type
Definition: json.hpp:7336
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
Definition: json.hpp:8648
void add(char_int_type c)
add a character to token_buffer
Definition: json.hpp:8619
void unget()
unget current character (read it again on next get)
Definition: json.hpp:8592
constexpr number_float_t get_number_float() const noexcept
return floating-point value
Definition: json.hpp:8642
static JSON_HEDLEY_PURE char get_decimal_point() noexcept
return the locale-dependent decimal point
Definition: json.hpp:7361
exception indicating other library errors
Definition: json.hpp:4426
static other_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4429
exception indicating access out of the defined range
Definition: json.hpp:4409
static out_of_range create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4412
Definition: json.hpp:14704
output_adapter(StringType &s)
Definition: json.hpp:14715
output_adapter(std::basic_ostream< CharType > &s)
Definition: json.hpp:14711
output_adapter(std::vector< CharType, AllocatorType > &vec)
Definition: json.hpp:14707
output adapter for output streams
Definition: json.hpp:14656
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
Definition: json.hpp:14658
void write_character(CharType c) override
Definition: json.hpp:14662
std::basic_ostream< CharType > & stream
Definition: json.hpp:14674
output adapter for basic_string
Definition: json.hpp:14681
void write_character(CharType c) override
Definition: json.hpp:14687
output_string_adapter(StringType &s) noexcept
Definition: json.hpp:14683
StringType & str
Definition: json.hpp:14699
output adapter for byte vectors
Definition: json.hpp:14631
std::vector< CharType, AllocatorType > & v
Definition: json.hpp:14649
output_vector_adapter(std::vector< CharType, AllocatorType > &vec) noexcept
Definition: json.hpp:14633
void write_character(CharType c) override
Definition: json.hpp:14637
exception indicating a parse error
Definition: json.hpp:4321
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, BasicJsonContext context)
create a parse error exception
Definition: json.hpp:4333
static std::string position_string(const position_t &pos)
Definition: json.hpp:4364
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4341
const std::size_t byte
byte index of the parse error
Definition: json.hpp:4358
parse_error(int id_, std::size_t byte_, const char *what_arg)
Definition: json.hpp:4361
syntax analysis
Definition: json.hpp:12038
std::string exception_message(const token_type expected, const std::string &context)
Definition: json.hpp:12443
parser(InputAdapterType &&adapter, const parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool skip_comments=false)
a parser reading from an input adapter
Definition: json.hpp:12048
typename lexer_t::token_type token_type
Definition: json.hpp:12044
void parse(const bool strict, BasicJsonType &result)
public parser interface
Definition: json.hpp:12070
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:12040
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:12039
typename BasicJsonType::string_t string_t
Definition: json.hpp:12042
lexer_t m_lexer
the lexer
Definition: json.hpp:12478
bool accept(const bool strict=true)
public accept interface
Definition: json.hpp:12130
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:12041
token_type get_token()
get next token from lexer
Definition: json.hpp:12438
Definition: json.hpp:12530
primitive_iterator_t & operator++() noexcept
Definition: json.hpp:12592
primitive_iterator_t & operator-=(difference_type n) noexcept
Definition: json.hpp:12624
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
Definition: json.hpp:12559
primitive_iterator_t & operator--() noexcept
Definition: json.hpp:12605
void set_end() noexcept
set iterator to a defined past the end
Definition: json.hpp:12553
friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.hpp:12575
constexpr bool is_end() const noexcept
return whether the iterator is at end
Definition: json.hpp:12565
primitive_iterator_t operator++(int) &noexcept
Definition: json.hpp:12598
primitive_iterator_t & operator+=(difference_type n) noexcept
Definition: json.hpp:12618
friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.hpp:12570
constexpr difference_type get_value() const noexcept
Definition: json.hpp:12541
friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.hpp:12587
primitive_iterator_t operator+(difference_type n) noexcept
Definition: json.hpp:12580
void set_begin() noexcept
set iterator to a defined beginning
Definition: json.hpp:12547
primitive_iterator_t operator--(int) &noexcept
Definition: json.hpp:12611
std::ptrdiff_t difference_type
Definition: json.hpp:12532
Definition: json.hpp:17727
typename BasicJsonType::binary_t::value_type binary_char_t
Definition: json.hpp:17732
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:17731
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
Definition: json.hpp:17742
serializer & operator=(const serializer &)=delete
const error_handler_t error_handler
error_handler how to react on decoding errors
Definition: json.hpp:18659
string_t indent_string
the indentation string
Definition: json.hpp:18656
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:17730
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:17729
serializer & operator=(serializer &&)=delete
typename BasicJsonType::string_t string_t
Definition: json.hpp:17728
const char indent_char
the indentation character
Definition: json.hpp:18654
void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent=0)
internal implementation of the serialization function
Definition: json.hpp:17782
serializer(const serializer &)=delete
serializer(serializer &&)=delete
exception indicating executing a member function with a wrong type
Definition: json.hpp:4392
static type_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition: json.hpp:4395
JSON Pointer defines a string syntax for identifying a specific value within a JSON document.
Definition: json.hpp:13596
BasicJsonType & get_checked(BasicJsonType *ptr) const
Definition: json.hpp:13982
json_pointer< string_t > convert() const &
Definition: json.hpp:14395
friend json_pointer operator/(const json_pointer &lhs, string_t token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
Definition: json.hpp:13691
static BasicJsonType::size_type array_index(const string_t &s)
Definition: json.hpp:13774
typename string_t_helper< RefStringType >::type string_t
Definition: json.hpp:13618
friend json_pointer operator/(const json_pointer &lhs, std::size_t array_idx)
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
Definition: json.hpp:13698
result reference_tokens
Definition: json.hpp:13820
json_pointer(const string_t &s="")
create JSON pointer
Definition: json.hpp:13622
static std::vector< string_t > split(const string_t &reference_string)
split the string input to reference tokens
Definition: json.hpp:14226
bool empty() const noexcept
return whether pointer points to the root document
Definition: json.hpp:13757
BasicJsonType & get_and_create(BasicJsonType &j) const
create and return a reference to the pointed to value
Definition: json.hpp:13834
void pop_back()
remove last reference token
Definition: json.hpp:13719
string_t to_string() const
return a string representation of the JSON pointer
Definition: json.hpp:13628
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
Definition: json.hpp:13676
void push_back(string_t &&token)
append an unescaped token at the end of the reference pointer
Definition: json.hpp:13750
json_pointer< string_t > convert() &&
Definition: json.hpp:14402
std::vector< string_t > reference_tokens
the reference tokens
Definition: json.hpp:14442
return result
Definition: json.hpp:13821
static void flatten(const string_t &reference_string, const BasicJsonType &value, BasicJsonType &result)
Definition: json.hpp:14295
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
Definition: json.hpp:13658
friend json_pointer operator/(const json_pointer &lhs, const json_pointer &rhs)
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
Definition: json.hpp:13683
BasicJsonType & get_unchecked(BasicJsonType *ptr) const
return a reference to the pointed to value
Definition: json.hpp:13914
json_pointer parent_pointer() const
returns the parent of this JSON pointer
Definition: json.hpp:13705
static BasicJsonType unflatten(const BasicJsonType &value)
Definition: json.hpp:14367
json_pointer & operator/=(string_t token)
append an unescaped reference token at the end of this JSON pointer
Definition: json.hpp:13668
const string_t & back() const
return last reference token
Definition: json.hpp:13731
friend std::ostream & operator<<(std::ostream &o, const json_pointer &ptr)
write string representation of the JSON pointer to stream
Definition: json.hpp:13649
const BasicJsonType & get_unchecked(const BasicJsonType *ptr) const
return a const reference to the pointed to value
Definition: json.hpp:14040
void push_back(const string_t &token)
append an unescaped token at the end of the reference pointer
Definition: json.hpp:13743
const BasicJsonType & get_checked(const BasicJsonType *ptr) const
Definition: json.hpp:14089
bool contains(const BasicJsonType *ptr) const
Definition: json.hpp:14138
decltype(get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
Definition: json.hpp:5231
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
Definition: json.hpp:2565
#define JSON_HEDLEY_CONST
Definition: json.hpp:1795
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
Definition: json.hpp:1079
#define JSON_INLINE_VARIABLE
Definition: json.hpp:2468
#define JSON_HEDLEY_WARN_UNUSED_RESULT
Definition: json.hpp:1425
#define JSON_PRIVATE_UNLESS_TESTED
Definition: json.hpp:2528
#define NLOHMANN_JSON_VERSION_PATCH
Definition: json.hpp:71
#define JSON_HEDLEY_LIKELY(expr)
Definition: json.hpp:1690
#define JSON_HEDLEY_NON_NULL(...)
Definition: json.hpp:1583
#define JSON_INTERNAL_CATCH(exception)
Definition: json.hpp:2495
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Definition: json.hpp:24041
#define JSON_HEDLEY_RETURNS_NON_NULL
Definition: json.hpp:2024
#define JSON_CATCH(exception)
Definition: json.hpp:2494
#define JSON_ASSERT(x)
Definition: json.hpp:2521
#define JSON_THROW(exception)
Definition: json.hpp:2492
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
Definition: json.hpp:78
#define NLOHMANN_JSON_VERSION_MAJOR
Definition: json.hpp:69
#define NLOHMANN_BASIC_JSON_TPL
Definition: json.hpp:2574
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1691
#define JSON_TRY
Definition: json.hpp:2493
#define NLOHMANN_JSON_NAMESPACE_END
Definition: json.hpp:124
#define JSON_NO_UNIQUE_ADDRESS
Definition: json.hpp:2474
#define NLOHMANN_JSON_VERSION_MINOR
Definition: json.hpp:70
bool operator==(json_pointer< RefStringTypeLhs > const &lhs, json_pointer< RefStringTypeRhs > const &rhs) noexcept
Definition: json.hpp:14447
#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name)
Definition: json.hpp:2749
bool operator!=(json_pointer< RefStringTypeLhs > const &lhs, json_pointer< RefStringTypeRhs > const &rhs) noexcept
Definition: json.hpp:14454
#define NLOHMANN_JSON_NAMESPACE_BEGIN
Definition: json.hpp:116
basic_json<> json
default specialization
Definition: json.hpp:3378
#define JSON_HEDLEY_DIAGNOSTIC_POP
Definition: json.hpp:1080
#define JSON_EXPLICIT
Definition: json.hpp:2786
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
Definition: json.hpp:1373
#define JSON_HEDLEY_PURE
Definition: json.hpp:1764
#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result)
Definition: json.hpp:22490
indent
Definition: convert.py:38
f
Definition: convert.py:38
int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)
Definition: json.hpp:17066
cached_power get_cached_power_for_binary_exponent(int e)
Definition: json.hpp:16902
Target reinterpret_bits(const Source source)
Definition: json.hpp:16622
boundaries compute_boundaries(FloatType value)
Definition: json.hpp:16763
void grisu2_round(char *buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k)
Definition: json.hpp:17120
constexpr int kAlpha
Definition: json.hpp:16885
void grisu2(char *buf, int &len, int &decimal_exponent, FloatType value)
Definition: json.hpp:17462
constexpr int kGamma
Definition: json.hpp:16886
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)
Definition: json.hpp:17161
JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent(char *buf, int e)
appends a decimal representation of e to buf
Definition: json.hpp:17502
JSON_HEDLEY_RETURNS_NON_NULL char * format_buffer(char *buf, int len, int decimal_exponent, int min_exp, int max_exp)
prettify v = buf * 10^decimal_exponent
Definition: json.hpp:17554
detail namespace with internal helper functions
Definition: json.hpp:226
input_format_t
the supported input formats
Definition: json.hpp:6020
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
Definition: json.hpp:5625
static void unescape(StringType &s)
string unescaping as described in RFC 6901 (Sect. 4)
Definition: json.hpp:2968
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
Definition: json.hpp:286
typename make_void< Ts... >::type void_t
Definition: json.hpp:232
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
Definition: json.hpp:8920
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
Definition: json.hpp:14626
decltype(std::declval< StringType & >()+=std::declval< Arg && >()) string_can_append_op
Definition: json.hpp:4125
decltype(std::declval< T & >().parse_error(std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
Definition: json.hpp:8928
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
Definition: json.hpp:12029
OutStringType concat(Args &&... args)
Definition: json.hpp:4199
is_detected< string_can_append_iter, StringType, Arg > detect_string_can_append_iter
Definition: json.hpp:4134
decltype(T::to_json(std::declval< Args >()...)) to_json_function
Definition: json.hpp:3473
decltype(std::declval< T >().template get< U >()) get_template_function
Definition: json.hpp:3479
typename std::conditional< is_usable_as_key_type< typename BasicJsonType::object_comparator_t, typename BasicJsonType::object_t::key_type, KeyTypeCVRef, RequireTransparentComparator, ExcludeObjectKeyType >::value &&!is_json_iterator_of< BasicJsonType, KeyType >::value, std::true_type, std::false_type >::type is_usable_as_basic_json_key_type
Definition: json.hpp:3917
JSON_HEDLEY_RETURNS_NON_NULL char * to_chars(char *first, const char *last, FloatType value)
generates a decimal representation of the floating-point number value in [first, last).
Definition: json.hpp:17639
void to_json(BasicJsonType &j, const T &b)
Definition: json.hpp:5619
typename T::pointer pointer_t
Definition: json.hpp:3464
parse_event_t
Definition: json.hpp:12012
@ value
the parser finished reading a JSON value
@ array_end
the parser read ] and finished processing a JSON array
@ array_start
the parser read [ and started to process a JSON array
@ object_start
the parser read { and started to process a JSON object
@ object_end
the parser read } and finished processing a JSON object
is_detected< string_can_append_op, StringType, Arg > detect_string_can_append_op
Definition: json.hpp:4128
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 > >, priority_tag< 0 >)
Definition: json.hpp:4861
integer_sequence< size_t, Ints... > index_sequence
Definition: json.hpp:3099
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
Definition: json.hpp:4672
typename utility_internal::Gen< T, N >::type make_integer_sequence
Definition: json.hpp:3145
typename T::value_type value_type_t
Definition: json.hpp:3458
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
Definition: json.hpp:290
T conditional_static_cast(U value)
Definition: json.hpp:3951
is_detected< string_can_append_data, StringType, Arg > detect_string_can_append_data
Definition: json.hpp:4140
typename std::enable_if< B, T >::type enable_if_t
Definition: json.hpp:3057
void from_json(const BasicJsonType &j, std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > &m)
Definition: json.hpp:4920
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
Definition: json.hpp:8889
typename T::mapped_type mapped_type_t
Definition: json.hpp:3452
void replace_substring(StringType &s, const StringType &f, const StringType &t)
replace all occurrences of a substring by another string
Definition: json.hpp:2934
decltype(std::declval< T & >().number_float(std::declval< Float >(), std::declval< const String & >())) number_float_function_t
Definition: json.hpp:8897
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
Definition: json.hpp:3645
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
Definition: json.hpp:5193
cbor_tag_handler_t
how to treat CBOR tags
Definition: json.hpp:9031
@ store
store tags as binary type
@ error
throw a parse_error exception in case of a tag
typename detected_or< Default, Op, Args... >::type detected_or_t
Definition: json.hpp:283
decltype(T::from_json(std::declval< Args >()...)) from_json_function
Definition: json.hpp:3476
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
Definition: json.hpp:6425
make_integer_sequence< size_t, N > make_index_sequence
Definition: json.hpp:3153
void concat_into(OutStringType &)
Definition: json.hpp:4115
typename T::key_type key_type_t
Definition: json.hpp:3455
constexpr bool value_in_range_of(T val)
Definition: json.hpp:4052
value_t
the JSON type enumeration
Definition: json.hpp:2836
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
std::integral_constant< bool, all_signed< Types... >::value||all_unsigned< Types... >::value > same_sign
Definition: json.hpp:3974
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
Definition: json.hpp:8905
std::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)> >, index_sequence< Idx... >)
Definition: json.hpp:4755
static bool little_endianness(int num=1) noexcept
determine system byte order
Definition: json.hpp:9044
typename detector< nonesuch, void, Op, Args... >::type detected_t
Definition: json.hpp:277
typename std::conditional< is_comparable< Comparator, ObjectKeyType, KeyTypeCVRef >::value &&!(ExcludeObjectKeyType &&std::is_same< KeyType, ObjectKeyType >::value) &&(!RequireTransparentComparator||is_detected< detect_is_transparent, Comparator >::value) &&!is_json_pointer< KeyType >::value, std::true_type, std::false_type >::type is_usable_as_key_type
Definition: json.hpp:3901
std::size_t hash(const BasicJsonType &j)
hash a JSON value
Definition: json.hpp:5867
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().begin(), std::declval< const Arg & >().end())) string_can_append_iter
Definition: json.hpp:4131
typename T::iterator_category iterator_category_t
Definition: json.hpp:3470
std::size_t combine(std::size_t seed, std::size_t h) noexcept
Definition: json.hpp:5849
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
Definition: json.hpp:2865
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
Definition: json.hpp:6368
decltype(std::declval< T & >().end_array()) end_array_function_t
Definition: json.hpp:8923
typename std::conditional< is_detected< detect_erase_with_key_type, typename BasicJsonType::object_t, KeyType >::value, std::true_type, std::false_type >::type has_erase_with_key_type
Definition: json.hpp:3929
error_handler_t
how to treat decoding errors
Definition: json.hpp:17719
@ strict
throw a type_error exception in case of invalid UTF-8
@ replace
replace invalid UTF-8 sequences with U+FFFD
std::size_t concat_length()
Definition: json.hpp:4084
value_type_t< iterator_traits< iterator_t< T > > > range_value_t
Definition: json.hpp:3648
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
Definition: json.hpp:4515
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
Definition: json.hpp:3552
decltype(std::declval< StringType & >().append(std::declval< Arg && >())) string_can_append
Definition: json.hpp:4119
void to_json(BasicJsonType &j, T b) noexcept
Definition: json.hpp:5493
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
Definition: json.hpp:4529
decltype(std::declval< T & >().null()) null_function_t
Definition: json.hpp:8881
make_index_sequence< sizeof...(Ts)> index_sequence_for
Definition: json.hpp:3161
typename T::difference_type difference_type_t
Definition: json.hpp:3461
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
Definition: json.hpp:3043
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
Definition: json.hpp:4855
typename T::is_transparent detect_is_transparent
Definition: json.hpp:3887
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
Definition: json.hpp:8901
typename T::reference reference_t
Definition: json.hpp:3467
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
Definition: json.hpp:8885
decltype(std::declval< T & >().end_object()) end_object_function_t
Definition: json.hpp:8916
decltype(std::declval< ObjectType & >().erase(std::declval< KeyType >())) detect_erase_with_key_type
Definition: json.hpp:3920
typename T::key_compare detect_key_compare
Definition: json.hpp:3536
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
Definition: json.hpp:8909
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().data(), std::declval< const Arg & >().size())) string_can_append_data
Definition: json.hpp:4137
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
Definition: json.hpp:8893
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
Definition: json.hpp:271
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
Definition: json.hpp:2953
void int_to_string(string_type &target, std::size_t value)
Definition: json.hpp:5030
std::integral_constant< bool,(std::is_signed< OfType >::value &&(sizeof(T)< sizeof(OfType)))||(same_sign< OfType, T >::value &&sizeof(OfType)==sizeof(T)) > never_out_of_range
Definition: json.hpp:3979
is_detected< string_can_append, StringType, Arg > detect_string_can_append
Definition: json.hpp:4122
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
Definition: json.hpp:8913
Definition: json.hpp:24047
name
Definition: setup.py:6
Definition: json.hpp:5214
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition: json.hpp:24114
namespace for Niels Lohmann
Definition: json.hpp:5678
static auto to_json(BasicJsonType &j, TargetType &&val) noexcept(noexcept(::nlohmann::to_json(j, std::forward< TargetType >(val)))) -> decltype(::nlohmann::to_json(j, std::forward< TargetType >(val)), void())
convert any value type to a JSON value
Definition: json.hpp:5702
static auto from_json(BasicJsonType &&j) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))
convert a JSON value to any value type
Definition: json.hpp:5692
static auto from_json(BasicJsonType &&j, TargetType &val) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), val))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), val), void())
convert a JSON value to any value type
Definition: json.hpp:5682
Definition: json.hpp:3544
typename BasicJsonType::object_t object_t
Definition: json.hpp:3545
typename BasicJsonType::default_object_comparator_t object_comparator_t
Definition: json.hpp:3546
typename std::conditional< has_key_compare< object_t >::value, typename object_t::key_compare, object_comparator_t >::type type
Definition: json.hpp:3548
Definition: json.hpp:3560
Definition: json.hpp:3559
std::true_type value_t
Definition: json.hpp:266
Op< Args... > type
Definition: json.hpp:267
std::false_type value_t
Definition: json.hpp:259
Default type
Definition: json.hpp:260
Definition: json.hpp:16750
diyfp w
Definition: json.hpp:16751
diyfp minus
Definition: json.hpp:16752
diyfp plus
Definition: json.hpp:16753
Definition: json.hpp:16889
std::uint64_t f
Definition: json.hpp:16890
int e
Definition: json.hpp:16891
int k
Definition: json.hpp:16892
Definition: json.hpp:16632
static diyfp mul(const diyfp &x, const diyfp &y) noexcept
returns x * y
Definition: json.hpp:16656
static diyfp normalize_to(const diyfp &x, const int target_exponent) noexcept
normalize x such that the result has the exponent E
Definition: json.hpp:16738
static diyfp normalize(diyfp x) noexcept
normalize x such that the significand is >= 2^(q-1)
Definition: json.hpp:16721
static diyfp sub(const diyfp &x, const diyfp &y) noexcept
returns x - y
Definition: json.hpp:16644
constexpr diyfp(std::uint64_t f_, int e_) noexcept
Definition: json.hpp:16638
std::uint64_t f
Definition: json.hpp:16635
int e
Definition: json.hpp:16636
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
Definition: json.hpp:5418
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
Definition: json.hpp:5393
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
Definition: json.hpp:5383
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
Definition: json.hpp:5405
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
Definition: json.hpp:5434
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
Definition: json.hpp:5322
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
Definition: json.hpp:5331
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
Definition: json.hpp:5276
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
Definition: json.hpp:5344
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
Definition: json.hpp:5370
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
Definition: json.hpp:5357
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
Definition: json.hpp:5453
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
Definition: json.hpp:5474
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
Definition: json.hpp:5463
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
Definition: json.hpp:5298
static void construct(BasicJsonType &j, const CompatibleStringType &str)
Definition: json.hpp:5309
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
Definition: json.hpp:5289
Definition: json.hpp:5270
Definition: json.hpp:4950
auto operator()(const BasicJsonType &j, T &&val) const noexcept(noexcept(from_json(j, std::forward< T >(val)))) -> decltype(from_json(j, std::forward< T >(val)))
Definition: json.hpp:4952
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: json.hpp:3498
Definition: json.hpp:3483
Definition: json.hpp:3539
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: json.hpp:3513
Definition: json.hpp:3508
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: json.hpp:3528
Definition: json.hpp:3523
Definition: json.hpp:4466
Definition: json.hpp:3085
T value_type
Definition: json.hpp:3086
static constexpr std::size_t size() noexcept
Definition: json.hpp:3087
an iterator value
Definition: json.hpp:12646
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition: json.hpp:12650
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition: json.hpp:12652
Definition: json.hpp:3432
Definition: json.hpp:3419
Definition: json.hpp:3878
Definition: json.hpp:3742
Definition: json.hpp:3761
std::numeric_limits< RealIntegerType > RealLimits
Definition: json.hpp:3819
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
Definition: json.hpp:3820
Definition: json.hpp:3809
Definition: json.hpp:3832
typename BasicJsonType::object_t object_t
Definition: json.hpp:3670
Definition: json.hpp:3662
Definition: json.hpp:3682
Definition: json.hpp:3719
static constexpr auto value
Definition: json.hpp:3720
Definition: json.hpp:3835
Definition: json.hpp:3848
Definition: json.hpp:3655
detail::is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< !std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value &&!is_compatible_string_type< BasicJsonType, ConstructibleArrayType >::value &&is_default_constructible< ConstructibleArrayType >::value &&(std::is_move_assignable< ConstructibleArrayType >::value||std::is_copy_assignable< ConstructibleArrayType >::value)&&is_detected< iterator_t, ConstructibleArrayType >::value &&is_iterator_traits< iterator_traits< detected_t< iterator_t, ConstructibleArrayType > > >::value &&is_detected< range_value_t, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, detected_t< range_value_t, ConstructibleArrayType > >::value &&is_complete_type< detected_t< range_value_t, ConstructibleArrayType > >::value > >::value_type range_value_t< ConstructibleArrayType > value_type
Definition: json.hpp:3791
Definition: json.hpp:3764
Definition: json.hpp:3805
typename BasicJsonType::object_t object_t
Definition: json.hpp:3694
Definition: json.hpp:3686
Definition: json.hpp:3715
Definition: json.hpp:3726
ConstructibleStringType laundered_type
Definition: json.hpp:3731
static constexpr auto value
Definition: json.hpp:3734
Definition: json.hpp:3851
Definition: json.hpp:3592
Definition: json.hpp:3572
Definition: json.hpp:3491
static constexpr bool value
Definition: json.hpp:3492
Definition: json.hpp:6344
typename std::iterator_traits< T >::value_type value_type
Definition: json.hpp:6345
Definition: json.hpp:3608
Definition: json.hpp:3857
Definition: json.hpp:3442
Definition: json.hpp:3939
char x[2]
Definition: json.hpp:3940
Definition: json.hpp:3935
static one test(decltype(&C::capacity))
@ value
Definition: json.hpp:3946
char one
Definition: json.hpp:3936
Definition: json.hpp:3627
detected_t< result_of_end, t_ref > sentinel
Definition: json.hpp:3632
detected_t< result_of_begin, t_ref > iterator
Definition: json.hpp:3631
typename std::add_lvalue_reference< T >::type t_ref
Definition: json.hpp:3629
static constexpr bool value
Definition: json.hpp:3641
static constexpr auto is_iterator_begin
Definition: json.hpp:3637
Definition: json.hpp:8963
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:8968
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:8969
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:8972
typename BasicJsonType::exception exception_t
Definition: json.hpp:8973
typename BasicJsonType::string_t string_t
Definition: json.hpp:8971
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:8970
Definition: json.hpp:8932
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:8941
typename BasicJsonType::exception exception_t
Definition: json.hpp:8942
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:8939
typename BasicJsonType::string_t string_t
Definition: json.hpp:8940
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:8938
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:8937
Definition: json.hpp:3868
T value_type
Definition: json.hpp:3261
T * pointer
Definition: json.hpp:3263
ptrdiff_t difference_type
Definition: json.hpp:3262
T & reference
Definition: json.hpp:3264
std::random_access_iterator_tag iterator_category
Definition: json.hpp:3260
Definition: json.hpp:3248
typename It::iterator_category iterator_category
Definition: json.hpp:3241
typename It::difference_type difference_type
Definition: json.hpp:3237
typename It::value_type value_type
Definition: json.hpp:3238
typename It::reference reference
Definition: json.hpp:3240
typename It::pointer pointer
Definition: json.hpp:3239
Definition: json.hpp:3229
void type
Definition: json.hpp:230
Definition: json.hpp:3566
nonesuch(nonesuch const &&)=delete
void operator=(nonesuch &&)=delete
void operator=(nonesuch const &)=delete
nonesuch(nonesuch const &)=delete
abstract output adapter interface
Definition: json.hpp:14612
output_adapter_protocol(const output_adapter_protocol &)=default
virtual ~output_adapter_protocol()=default
virtual void write_character(CharType c)=0
output_adapter_protocol(output_adapter_protocol &&) noexcept=default
output_adapter_protocol()=default
virtual void write_characters(const CharType *s, std::size_t length)=0
struct to capture the start position of the current token
Definition: json.hpp:2999
std::size_t chars_read_current_line
the number of characters read in the current line
Definition: json.hpp:3003
std::size_t lines_read
the number of lines read
Definition: json.hpp:3005
std::size_t chars_read_total
the total number of characters read
Definition: json.hpp:3001
Definition: json.hpp:3169
Definition: json.hpp:3168
Definition: json.hpp:3174
static constexpr T value
Definition: json.hpp:3175
Definition: json.hpp:5645
auto operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(to_json(j, std::forward< T >(val)))) -> decltype(to_json(j, std::forward< T >(val)), void())
Definition: json.hpp:5647
Definition: json.hpp:3105
Definition: json.hpp:3124
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
Definition: json.hpp:3126
static constexpr bool test(T val)
Definition: json.hpp:4036
static constexpr bool test(T)
Definition: json.hpp:4045
Definition: json.hpp:4031
static constexpr bool test(T val)
Definition: json.hpp:3989
static constexpr bool test(T val)
Definition: json.hpp:4009
static constexpr bool test(T val)
Definition: json.hpp:3999
static constexpr bool test(T val)
Definition: json.hpp:4020
Definition: json.hpp:3984
StringType type
Definition: json.hpp:13613
Definition: json.hpp:13606
T type
Definition: json.hpp:13607
SAX interface.
Definition: json.hpp:6517
virtual bool binary(binary_t &val)=0
a binary value was read
virtual bool number_float(number_float_t val, const string_t &s)=0
a floating-point number was read
virtual bool number_unsigned(number_unsigned_t val)=0
an unsigned integer number was read
virtual bool key(string_t &val)=0
an object key was read
virtual bool string(string_t &val)=0
a string value was read
virtual bool number_integer(number_integer_t val)=0
an integer number was read
virtual bool start_object(std::size_t elements)=0
the beginning of an object was read
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:6518
typename BasicJsonType::string_t string_t
Definition: json.hpp:6521
virtual bool end_array()=0
the end of an array was read
json_sax(const json_sax &)=default
virtual bool boolean(bool val)=0
a boolean value was read
virtual bool end_object()=0
the end of an object was read
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:6520
virtual bool null()=0
a null value was read
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:6519
json_sax(json_sax &&) noexcept=default
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:6522
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex)=0
a parse error occurred
virtual bool start_array(std::size_t elements)=0
the beginning of an array was read
a minimal map-like container that preserves insertion order
Definition: json.hpp:18701
std::vector< std::pair< const Key, T >, Allocator > Container
Definition: json.hpp:18704
std::pair< iterator, bool > insert(value_type &&value)
Definition: json.hpp:18995
typename Container::value_type value_type
Definition: json.hpp:18708
std::equal_to< Key > key_compare
Definition: json.hpp:18712
iterator erase(iterator pos)
Definition: json.hpp:18873
T mapped_type
Definition: json.hpp:18703
ordered_map(const Allocator &alloc) noexcept(noexcept(Container(alloc)))
Definition: json.hpp:18718
T & operator[](KeyType &&key)
Definition: json.hpp:18760
typename Container::iterator iterator
Definition: json.hpp:18705
const T & at(KeyType &&key) const
Definition: json.hpp:18820
T & at(KeyType &&key)
Definition: json.hpp:18792
const T & operator[](KeyType &&key) const
Definition: json.hpp:18772
iterator find(const key_type &key)
Definition: json.hpp:18957
iterator erase(iterator first, iterator last)
Definition: json.hpp:18878
const T & at(const key_type &key) const
Definition: json.hpp:18805
const_iterator find(const key_type &key) const
Definition: json.hpp:18983
T & operator[](const key_type &key)
Definition: json.hpp:18753
size_type erase(KeyType &&key)
Definition: json.hpp:18854
typename Container::size_type size_type
Definition: json.hpp:18707
ordered_map() noexcept(noexcept(Container()))
Definition: json.hpp:18717
void insert(InputIt first, InputIt last)
Definition: json.hpp:19018
size_type count(const key_type &key) const
Definition: json.hpp:18931
std::pair< iterator, bool > emplace(KeyType &&key, T &&t)
Definition: json.hpp:18740
size_type erase(const key_type &key)
Definition: json.hpp:18833
ordered_map(std::initializer_list< value_type > init, const Allocator &alloc=Allocator())
Definition: json.hpp:18722
std::pair< iterator, bool > insert(const value_type &value)
Definition: json.hpp:19000
size_type count(KeyType &&key) const
Definition: json.hpp:18945
Key key_type
Definition: json.hpp:18702
ordered_map(It first, It last, const Allocator &alloc=Allocator())
Definition: json.hpp:18720
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
Definition: json.hpp:19015
const T & operator[](const key_type &key) const
Definition: json.hpp:18765
iterator find(KeyType &&key)
Definition: json.hpp:18971
T & at(const key_type &key)
Definition: json.hpp:18777
typename Container::const_iterator const_iterator
Definition: json.hpp:18706
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
Definition: json.hpp:18725
std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
Definition: json.hpp:24083
bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values
Definition: json.hpp:24097